-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
glTF parse support custom extsnions and parser #1008
glTF parse support custom extsnions and parser #1008
Conversation
# Conflicts: # packages/loader/src/index.ts
Codecov ReportBase: 41.83% // Head: 41.93% // Increases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## dev/1.0 #1008 +/- ##
===========================================
+ Coverage 41.83% 41.93% +0.10%
===========================================
Files 351 351
Lines 17778 17795 +17
Branches 2605 2610 +5
===========================================
+ Hits 7438 7463 +25
+ Misses 9650 9638 -12
- Partials 690 694 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -12,3 +12,6 @@ import "./KHR_mesh_quantization"; | |||
import "./KHR_texture_basisu"; | |||
import "./KHR_texture_transform"; | |||
import "./OASIS_materials_remap"; | |||
|
|||
export { GLTFExtensionParser } from "./GLTFExtensionParser"; | |||
export * from "./Schema"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename GLTFSchema
to GLTFExtensions.d.ts
|
||
parse(context: GLTFParserContext): AssetPromise<GLTFResource> { | ||
const glTFResource = context.glTFResource; | ||
let lastParser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add type
/**
* Base class of glTF extension parser.
*/
export abstract class GLTFExtensionParser {
/** The extension mode. */
abstract readonly mode: GLTFExtensionMode;
/**
* Create a resource instance.
* @remarks This method overrides the default resource creation
* @param context - The parser context
* @param extensionSchema - The extension schema
* @param ownerSchema - The extension owner schema
* @returns The resource or promise
*/
createAndParse(
context: GLTFParserContext,
extensionSchema: GLTFExtensionSchema,
ownerSchema: GLTFExtensionOwnerSchema
): EngineObject | Promise<EngineObject> {
throw "Not implemented.";
}
/**
* Additive parse to the resource.
* @param context - The parser context
* @param resource - The resource
* @param extensionSchema - The extension schema
* @param ownerSchema - The extension owner schema
* @returns The void or promise
*/
additiveParse(
context: GLTFParserContext,
resource: EngineObject,
extensionSchema: GLTFExtensionSchema,
ownerSchema: GLTFExtensionOwnerSchema
): void | Promise<void> {
throw "Not implemented.";
}
}
/**
* glTF Extension mode.
*/
enum GLTFExtensionMode {
/** Cerate instance and parse mode, `createAndParse()` will be called when resource instance, usually only one in the extension owner schema. */
CreateAndParse,
/** Additive parse mode, `additiveParse()` will be called when resource parse, can be multiple in extension owner schema. */
AdditiveParse
}
export type GLTFExtensionOwnerSchema = IMeshPrimitive | IMaterial | ITexture | INode;
export type GLTFExtensionSchema =
| IKHRLightsPunctual_Light
| IKHRDracoMeshCompression
| IKHRMaterialsClearcoat
| IKHRMaterialsIor
| IKHRMaterialsUnlit
| IKHRMaterialsPbrSpecularGlossiness
| IKHRMaterialsSheen
| IKHRMaterialsSpecular
| IKHRMaterialsTransmission
| IKHRMaterialsTranslucency
| IKHRMaterialVariants_Mapping
| IKHRMaterialVariants_Variants
| IKHRTextureBasisU
| IKHRTextureTransform
| IKHRXmp
| IKHRXmp_Node
| object; |
packages/loader/src/gltf/extensions/KHR_materials_pbrSpecularGlossiness.ts
Outdated
Show resolved
Hide resolved
…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)
* dev/1.0: (41 commits) fix: package.json Support device lost (galacean#1374) "v0.9.0-beta.70" fix: add shadow parser (galacean#1411) Add `toJSON` in base math class (galacean#1380) (galacean#1409) refactor(particle): Add an infinite bounding box to the particle system and it will never be clipped (galacean#1410) "v0.9.0-beta.69" Fix glTF SkinnedMeshRenderer default local bounds (galacean#1405) Support shader replacement and sub shader (galacean#1394) Fix camera cull bug (galacean#1396) "v0.9.0-beta.68" fix: InputManager default listener target "v0.9.0-beta.67" Fix shader compile performance on some windows device (galacean#1390) 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 ...
* feat: glTF parse support custom extsnions and parser Co-authored-by: ChenMo <gl3336563@163.com>
* glTF parse support custom extsnions and parser (#1008) * feat: glTF parse support custom extsnions and parser Co-authored-by: ChenMo <gl3336563@163.com> Co-authored-by: zhuxudong <callzhuxudong@163.com>
举个例子,如果 Unity 导出了以下 glTF 插件,希望能根据材质拓展
Unity_Material_Plugin
生成新的自定义材质,然后根据灯光插件Unity_Light_Plugin
表示想在某个节点上面加一个灯光:1. 自定义创建解析
按照上面的例子,我们注册一个材质插件,第二个参数
GLTFExtensionMode.CreateAndParse
表示这个插件是用来创建实例和解析的:2. 增量解析
按照上面的例子,我们注册一个灯光插件,第二个参数
GLTFExtensionMode.AdditiveParse
表示这个插件是在原来实例的基础上进行一些增量解析的,比如在这个实体上添加一个光源:3. 自定义管线
如果上面的方法还不能满足您的需求,还可以完全自定义解析管线,用来重写解析的逻辑: