forked from galacean/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'add6e916a8327e492f8fec16bc0e7cd543a59566' into pr/conte…
…xt-restore * commit 'add6e916a8327e492f8fec16bc0e7cd543a59566': Move font map cache from `Font` to `Engine` (galacean#1387) "v1.0.0-alpha.0" glTF parse support custom extsnions and parser (galacean#1008) Optimization `Transform` direction related API (galacean#1381) refactor: opt code refactor: opt code refactor: opt code refactor: opt code refactor: opt code feat: refactor transform API Add `toJSON` in base math class (galacean#1380)
- Loading branch information
Showing
29 changed files
with
262 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { AssetPromise } from "@oasis-engine/core"; | ||
import { GLTFResource } from "./GLTFResource"; | ||
import { GLTFAnimationParser } from "./parser/GLTFAnimationParser"; | ||
import { GLTFBufferParser } from "./parser/GLTFBufferParser"; | ||
import { GLTFEntityParser } from "./parser/GLTFEntityParser"; | ||
import { GLTFMaterialParser } from "./parser/GLTFMaterialParser"; | ||
import { GLTFMeshParser } from "./parser/GLTFMeshParser"; | ||
import { GLTFParser } from "./parser/GLTFParser"; | ||
import { GLTFParserContext } from "./parser/GLTFParserContext"; | ||
import { GLTFSceneParser } from "./parser/GLTFSceneParser"; | ||
import { GLTFSkinParser } from "./parser/GLTFSkinParser"; | ||
import { GLTFTextureParser } from "./parser/GLTFTextureParser"; | ||
import { GLTFValidator } from "./parser/GLTFValidator"; | ||
|
||
/** | ||
* GLTF pipeline. | ||
*/ | ||
export class GLTFPipeline { | ||
/** | ||
* Default pipeline. | ||
*/ | ||
static defaultPipeline = new GLTFPipeline( | ||
GLTFBufferParser, | ||
GLTFValidator, | ||
GLTFTextureParser, | ||
GLTFMaterialParser, | ||
GLTFMeshParser, | ||
GLTFEntityParser, | ||
GLTFSkinParser, | ||
GLTFAnimationParser, | ||
GLTFSceneParser | ||
); | ||
|
||
private _parsers: GLTFParser[] = []; | ||
|
||
/** | ||
* Constructor of GLTFPipeline. | ||
* @param parsers - Parsers to be executed in order | ||
*/ | ||
constructor(...parsers: (new () => GLTFParser)[]) { | ||
parsers.forEach((pipe: new () => GLTFParser, index: number) => { | ||
this._parsers[index] = new pipe(); | ||
}); | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
_parse(context: GLTFParserContext): AssetPromise<GLTFResource> { | ||
const glTFResource = context.glTFResource; | ||
let lastParser; | ||
|
||
return new AssetPromise<GLTFResource>((resolve, reject) => { | ||
this._parsers.forEach((parser: GLTFParser) => { | ||
if (lastParser) { | ||
lastParser = lastParser.then(() => { | ||
return parser.parse(context); | ||
}); | ||
if (lastParser.cancel) { | ||
context.chainPromises.push(lastParser); | ||
} | ||
} else { | ||
lastParser = parser.parse(context); | ||
} | ||
}); | ||
|
||
if (lastParser) { | ||
lastParser | ||
.then(() => { | ||
resolve(glTFResource); | ||
}) | ||
.catch(reject); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.