Skip to content

Commit

Permalink
fix meshopt offset mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsErdkamp committed May 27, 2024
1 parent 9929b1b commit 9427c12
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 34 deletions.
Binary file removed serve/assets/vase/.DS_Store
Binary file not shown.
73 changes: 40 additions & 33 deletions serve/src/index.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
let app = new PIXI.Application({
backgroundColor: 0xdddddd, resizeTo: window, antialias: true
})
document.body.appendChild(app.view)
globalThis.__PIXI_APP__ = app
backgroundColor: 0xdddddd,
resizeTo: window,
antialias: true,
});
document.body.appendChild(app.view);
globalThis.__PIXI_APP__ = app;

let control = new PIXI3D.CameraOrbitControl(app.view)
control.enableDamping = true
let control = new PIXI3D.CameraOrbitControl(app.view);
control.enableDamping = true;

app.loader.add("assets/chromatic/diffuse.cubemap")
app.loader.add("assets/chromatic/specular.cubemap")
app.loader.add("assets/teapot/teapot.gltf")
app.loader.add("assets/chromatic/diffuse.cubemap");
app.loader.add("assets/chromatic/specular.cubemap");
app.loader.add("assets/teapot/teapot-meshopt.glb");

app.loader.load((_, resources) => {
PIXI3D.LightingEnvironment.main.imageBasedLighting = new PIXI3D.ImageBasedLighting(
resources["assets/chromatic/diffuse.cubemap"].cubemap,
resources["assets/chromatic/specular.cubemap"].cubemap
)
PIXI3D.LightingEnvironment.main.imageBasedLighting =
new PIXI3D.ImageBasedLighting(
resources["assets/chromatic/diffuse.cubemap"].cubemap,
resources["assets/chromatic/specular.cubemap"].cubemap
);

let model = app.stage.addChild(
PIXI3D.Model.from(resources["assets/teapot/teapot.gltf"].gltf))
model.y = -0.8
model.meshes.forEach(mesh => {
mesh.material.exposure = 1.3
})
PIXI3D.Model.from(resources["assets/teapot/teapot-meshopt.glb"].gltf)
);
model.y = -0.8;
model.meshes.forEach((mesh) => {
mesh.material.exposure = 1.3;
});

let ground = app.stage.addChild(PIXI3D.Mesh3D.createPlane())
ground.y = -0.8
ground.scale.set(10, 1, 10)
let ground = app.stage.addChild(PIXI3D.Mesh3D.createPlane());
ground.y = -0.8;
ground.scale.set(10, 1, 10);

let directionalLight = Object.assign(new PIXI3D.Light(), {
intensity: 1,
type: "directional"
})
directionalLight.rotationQuaternion.setEulerAngles(25, 120, 0)
PIXI3D.LightingEnvironment.main.lights.push(directionalLight)
type: "directional",
});
directionalLight.rotationQuaternion.setEulerAngles(25, 120, 0);
PIXI3D.LightingEnvironment.main.lights.push(directionalLight);

let shadowCastingLight = new PIXI3D.ShadowCastingLight(
app.renderer, directionalLight, { shadowTextureSize: 1024, quality: PIXI3D.ShadowQuality.medium })
shadowCastingLight.softness = 1
shadowCastingLight.shadowArea = 15

let pipeline = app.renderer.plugins.pipeline
pipeline.enableShadows(ground, shadowCastingLight)
pipeline.enableShadows(model, shadowCastingLight)
})
app.renderer,
directionalLight,
{ shadowTextureSize: 1024, quality: PIXI3D.ShadowQuality.medium }
);
shadowCastingLight.softness = 1;
shadowCastingLight.shadowArea = 15;

let pipeline = app.renderer.plugins.pipeline;
pipeline.enableShadows(ground, shadowCastingLight);
pipeline.enableShadows(model, shadowCastingLight);
});
4 changes: 3 additions & 1 deletion src/gltf/gltf-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export class glTFParser {
}
let bufferView = this._descriptor.bufferViews[accessor.bufferView || 0];
let offset = accessor.byteOffset || 0;

if (bufferView.byteOffset !== undefined) {
offset += bufferView.byteOffset;
}

let size = accessor.count * componentCount[accessor.type];
if (bufferView.byteStride !== undefined && bufferView.byteStride !== 0) {
size =
Expand All @@ -96,7 +98,7 @@ export class glTFParser {
if (bufferView.extensions?.EXT_meshopt_compression != undefined) {
const meshoptExtension = bufferView.extensions.EXT_meshopt_compression;
buffer = this.decodeMeshoptBuffer(meshoptExtension);
offset = 0;
offset = accessor.byteOffset || 0;
}

return glTFAttribute.from(
Expand Down

0 comments on commit 9427c12

Please sign in to comment.