Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rhodonite v0.12.4 to v0.12.7 #132

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/rhodonite/oimo/domino/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script type="importmap">
{
"imports": {
"rhodonite": "https://cx20.github.io/gltf-test/libs/rhodonite/v0.12.4/esm/index.js"
"rhodonite": "https://cx20.github.io/gltf-test/libs/rhodonite/v0.12.7/esm/index.js"
}
}
</script>
Expand Down
41 changes: 23 additions & 18 deletions examples/rhodonite/oimo/domino/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,34 @@ const load = async function() {
await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');

const texture = new Rn.Texture();
texture.generateTextureFromUri('../../../../assets/textures/grass.jpg');

const c = document.getElementById('world');
const gl = await Rn.System.init({
approach: Rn.ProcessApproach.DataTexture,
canvas: c

await Rn.System.init({
approach: Rn.ProcessApproach.DataTexture,
canvas: c,
});
gl.enable(gl.DEPTH_TEST);

resizeCanvas();

window.addEventListener("resize", function() {
window.addEventListener("resize", function(){
resizeCanvas();
});

function resizeCanvas() {
c.width = window.innerWidth;
c.height = window.innerHeight;
gl.viewport(0, 0, c.width, c.height);
Rn.System.resizeCanvas(window.innerWidth, window.innerHeight);
}

const texture = new Rn.Texture();
texture.generateTextureFromUri('../../../../assets/textures/grass.jpg');

const sampler = new Rn.Sampler({
magFilter: Rn.TextureParameter.Linear,
minFilter: Rn.TextureParameter.Linear,
wrapS: Rn.TextureParameter.ClampToEdge,
wrapT: Rn.TextureParameter.ClampToEdge,
});
sampler.create();

const entity1 = Rn.MeshHelper.createCube({
physics: {
use: true,
Expand All @@ -97,11 +103,10 @@ const load = async function() {
value: "ground"
});
entity1.scale = Rn.Vector3.fromCopyArray([200 * PHYSICS_SCALE, 2 * PHYSICS_SCALE, 200 * PHYSICS_SCALE]);
entity1.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
entity1.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);
entities.push(entity1);


populate(texture);
populate(texture, sampler);

const startTime = Date.now();

Expand Down Expand Up @@ -136,7 +141,7 @@ const load = async function() {

}

function populate(texture) {
function populate(texture, sampler) {
let max = 256;
let w = DOT_SIZE * 0.2;
let h = DOT_SIZE * 1.5;
Expand Down Expand Up @@ -174,7 +179,7 @@ function populate(texture) {
});
entity.position = Rn.Vector3.fromCopyArray([(-8 + x) * DOT_SIZE * PHYSICS_SCALE, y * DOT_SIZE * PHYSICS_SCALE, (-8 + z) * DOT_SIZE * 1.2 * PHYSICS_SCALE]);
entity.scale = Rn.Vector3.fromCopyArray([w * PHYSICS_SCALE, h * PHYSICS_SCALE, d * PHYSICS_SCALE]);
entity.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
entity.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);
entities.push(entity);

}
Expand Down Expand Up @@ -211,7 +216,7 @@ function populate(texture) {
});
entity.position = Rn.Vector3.fromCopyArray([(-8.4 + x) * DOT_SIZE * PHYSICS_SCALE, y * DOT_SIZE * PHYSICS_SCALE, (-8 + z) * DOT_SIZE * 1.2 * PHYSICS_SCALE]);
entity.scale = Rn.Vector3.fromCopyArray([w * PHYSICS_SCALE, h * PHYSICS_SCALE, d * PHYSICS_SCALE]);
entity.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
entity.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);
entities.push(entity);

}
Expand Down
2 changes: 1 addition & 1 deletion examples/rhodonite/oimo/minimum/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script type="importmap">
{
"imports": {
"rhodonite": "https://cx20.github.io/gltf-test/libs/rhodonite/v0.12.4/esm/index.js"
"rhodonite": "https://cx20.github.io/gltf-test/libs/rhodonite/v0.12.7/esm/index.js"
}
}
</script>
Expand Down
29 changes: 18 additions & 11 deletions examples/rhodonite/oimo/minimum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,35 @@ const load = async function() {
await Rn.ModuleManager.getInstance().loadModule('webgl');
await Rn.ModuleManager.getInstance().loadModule('pbr');
const c = document.getElementById('world');
const gl = await Rn.System.init({
approach: Rn.ProcessApproach.DataTexture,
canvas: c

await Rn.System.init({
approach: Rn.ProcessApproach.DataTexture,
canvas: c,
});

resizeCanvas();

window.addEventListener("resize", function() {
window.addEventListener("resize", function(){
resizeCanvas();
});

function resizeCanvas() {
c.width = window.innerWidth;
c.height = window.innerHeight;
gl.viewport(0, 0, c.width, c.height);
Rn.System.resizeCanvas(window.innerWidth, window.innerHeight);
}

const entities = [];

const texture = new Rn.Texture();
texture.generateTextureFromUri('../../../../assets/textures/frog.jpg');

const sampler = new Rn.Sampler({
magFilter: Rn.TextureParameter.Linear,
minFilter: Rn.TextureParameter.Linear,
wrapS: Rn.TextureParameter.ClampToEdge,
wrapT: Rn.TextureParameter.ClampToEdge,
});
sampler.create();

// Ground
const entity1 = Rn.MeshHelper.createCube({
physics: {
Expand All @@ -43,7 +50,7 @@ const load = async function() {
value: "ground"
});
entity1.scale = Rn.Vector3.fromCopyArray([200 / 2 * PHYSICS_SCALE, 2 / 2 * PHYSICS_SCALE, 200 / 2 * PHYSICS_SCALE]);
entity1.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
entity1.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);
entities.push(entity1);

// Cube
Expand All @@ -62,7 +69,7 @@ const load = async function() {
});
entity2.position = Rn.Vector3.fromCopyArray([0, 100 * PHYSICS_SCALE, 0]);
entity2.scale = Rn.Vector3.fromCopyArray([50 / 2 * PHYSICS_SCALE, 50 / 2 * PHYSICS_SCALE, 50 / 2 * PHYSICS_SCALE]);
entity2.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
entity2.getMesh().mesh.getPrimitiveAt(0).material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture, sampler);
entities.push(entity2);

const startTime = Date.now();
Expand Down