Skip to content

Commit 8f3210f

Browse files
committed
adjust test (passes test)
1 parent 4cf2aa7 commit 8f3210f

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/gltf/gltf-parser.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ export class glTFParser {
3232
* Creates a new parser using the specified asset.
3333
* @param asset The asset to parse.
3434
* @param materialFactory The material factory to use.
35-
* @param meshoptDecoder optionally provide meshoptDecoder to parse meshopt meshes.
35+
* @param meshoptDecoder provide meshoptimizer's meshoptDecoder to parse meshopt meshes.
3636
*/
37-
constructor(asset: glTFAsset, materialFactory?: MaterialFactory, meshoptDecoder?: any) {
37+
constructor(
38+
asset: glTFAsset,
39+
materialFactory?: MaterialFactory,
40+
meshoptDecoder?: any
41+
) {
3842
this._asset = asset;
3943
this._materialFactory = materialFactory || new StandardMaterialFactory();
4044
this._descriptor = this._asset.descriptor;
@@ -52,7 +56,11 @@ export class glTFParser {
5256
* @param asset The asset to create the model from.
5357
* @param materialFactory The material factory to use.
5458
*/
55-
static createModel(asset: glTFAsset, materialFactory?: MaterialFactory, meshoptDecoder ?: any) {
59+
static createModel(
60+
asset: glTFAsset,
61+
materialFactory?: MaterialFactory,
62+
meshoptDecoder?: any
63+
) {
5664
return new glTFParser(asset, materialFactory, meshoptDecoder).parseModel();
5765
}
5866

@@ -100,15 +108,18 @@ export class glTFParser {
100108
let buffer = this._asset.buffers[bufferView.buffer];
101109

102110
if (bufferView.extensions?.EXT_meshopt_compression != undefined) {
103-
104-
if (this._meshoptDecoder == undefined) {
105-
console.error('Buffer uses EXT_meshopt_compression but meshoptDecoder is not provided.');
106-
return;
111+
if (this._meshoptDecoder != undefined) {
112+
const meshoptExtension = bufferView.extensions.EXT_meshopt_compression;
113+
buffer = this.decodeMeshoptBuffer(
114+
meshoptExtension,
115+
accessor.bufferView
116+
);
117+
offset = accessor.byteOffset || 0;
118+
} else {
119+
console.error(
120+
"Buffer uses EXT_meshopt_compression but meshoptDecoder is not provided."
121+
);
107122
}
108-
109-
const meshoptExtension = bufferView.extensions.EXT_meshopt_compression;
110-
buffer = this.decodeMeshoptBuffer(meshoptExtension, accessor.bufferView);
111-
offset = accessor.byteOffset || 0;
112123
}
113124

114125
return glTFAttribute.from(

test/gltf.test.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from "chai";
2+
import { MeshoptDecoder } from "meshoptimizer";
23

34
describe("glTF", () => {
45
it("should render separate correctly using pixi *.*.*", async () => {
@@ -52,7 +53,9 @@ describe("glTF", () => {
5253
it("should render meshopt correctly using pixi *.*.*", async () => {
5354
let render = (renderer, resources) => {
5455
let model = PIXI3D.Model.from(
55-
resources["assets/teapot/teapot-binary-meshopt.glb"].gltf
56+
resources["assets/teapot/teapot-binary-meshopt.glb"].gltf,
57+
undefined,
58+
MeshoptDecoder
5659
);
5760
model.y = -0.8;
5861
model.meshes.forEach((mesh) => {

0 commit comments

Comments
 (0)