Skip to content

Commit

Permalink
Merge pull request #132 from cx20/update_rhodonite_to_latest
Browse files Browse the repository at this point in the history
Update Rhodonite v0.12.4 to v0.12.7
  • Loading branch information
cx20 authored Jun 15, 2024
2 parents d4f4a57 + f7d6bbb commit 3eb1f77
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
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

0 comments on commit 3eb1f77

Please sign in to comment.