@babylonjs/loaders 8.10.0 → 8.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +7 -8
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +2 -3
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +2 -2
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.js +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +10 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +2 -2
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/package.json +3 -3
@@ -3,7 +3,6 @@ import type { IGLTF } from "../../glTFLoaderInterfaces.js";
|
|
3
3
|
import type { IGLTFToFlowGraphMapping } from "./declarationMapper.js";
|
4
4
|
import type { ISerializedFlowGraph, ISerializedFlowGraphBlock } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
|
5
5
|
import { FlowGraphTypes } from "@babylonjs/core/FlowGraph/flowGraphRichTypes.js";
|
6
|
-
import type { GLTFLoader } from "../../glTFLoader.js";
|
7
6
|
export interface InteractivityEvent {
|
8
7
|
eventId: string;
|
9
8
|
eventData?: {
|
@@ -23,7 +22,7 @@ export declare const gltfTypeToBabylonType: {
|
|
23
22
|
export declare class InteractivityGraphToFlowGraphParser {
|
24
23
|
private _interactivityGraph;
|
25
24
|
private _gltf;
|
26
|
-
|
25
|
+
_animationTargetFps: number;
|
27
26
|
/**
|
28
27
|
* Note - the graph should be rejected if the same type is defined twice.
|
29
28
|
* We currently don't validate that.
|
@@ -34,7 +33,7 @@ export declare class InteractivityGraphToFlowGraphParser {
|
|
34
33
|
private _events;
|
35
34
|
private _internalEventsCounter;
|
36
35
|
private _nodes;
|
37
|
-
constructor(_interactivityGraph: IKHRInteractivity_Graph, _gltf: IGLTF,
|
36
|
+
constructor(_interactivityGraph: IKHRInteractivity_Graph, _gltf: IGLTF, _animationTargetFps?: number);
|
38
37
|
get arrays(): {
|
39
38
|
types: {
|
40
39
|
length: number;
|
@@ -14,10 +14,10 @@ export const gltfTypeToBabylonType = {
|
|
14
14
|
int: { length: 1, flowGraphType: "FlowGraphInteger" /* FlowGraphTypes.Integer */, elementType: "number" },
|
15
15
|
};
|
16
16
|
export class InteractivityGraphToFlowGraphParser {
|
17
|
-
constructor(_interactivityGraph, _gltf,
|
17
|
+
constructor(_interactivityGraph, _gltf, _animationTargetFps = 60) {
|
18
18
|
this._interactivityGraph = _interactivityGraph;
|
19
19
|
this._gltf = _gltf;
|
20
|
-
this.
|
20
|
+
this._animationTargetFps = _animationTargetFps;
|
21
21
|
/**
|
22
22
|
* Note - the graph should be rejected if the same type is defined twice.
|
23
23
|
* We currently don't validate that.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"interactivityGraphParser.js","sourceRoot":"","sources":["../../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAiB5C,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAE9B;IACA,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,sCAAuB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACjF,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,E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,iBAAiB,EAAE,CAAC,OAAO,CAAC;SAC/B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { IKHRInteractivity_Graph, IKHRInteractivity_Node, IKHRInteractivity_OutputSocketReference, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\nimport type { IGLTF } from \"../../glTFLoaderInterfaces\";\nimport type { IGLTFToFlowGraphMapping } from \"./declarationMapper\";\nimport { getMappingForDeclaration, getMappingForFullOperationName } from \"./declarationMapper\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\nimport { RandomGUID } from \"core/Misc/guid\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { GLTFLoader } from \"../../glTFLoader\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface InteractivityEvent {\n eventId: string;\n eventData?: {\n eventData: boolean;\n id: string;\n type: string;\n value?: any;\n }[];\n}\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const gltfTypeToBabylonType: {\n [key: string]: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" };\n} = {\n float: { length: 1, flowGraphType: FlowGraphTypes.Number, elementType: \"number\" },\n bool: { length: 1, flowGraphType: FlowGraphTypes.Boolean, elementType: \"boolean\" },\n float2: { length: 2, flowGraphType: FlowGraphTypes.Vector2, elementType: \"number\" },\n float3: { length: 3, flowGraphType: FlowGraphTypes.Vector3, elementType: \"number\" },\n float4: { length: 4, flowGraphType: FlowGraphTypes.Vector4, elementType: \"number\" },\n float4x4: { length: 16, flowGraphType: FlowGraphTypes.Matrix, elementType: \"number\" },\n float2x2: { length: 4, flowGraphType: FlowGraphTypes.Matrix2D, elementType: \"number\" },\n float3x3: { length: 9, flowGraphType: FlowGraphTypes.Matrix3D, elementType: \"number\" },\n int: { length: 1, flowGraphType: FlowGraphTypes.Integer, elementType: \"number\" },\n};\n\nexport class InteractivityGraphToFlowGraphParser {\n /**\n * Note - the graph should be rejected if the same type is defined twice.\n * We currently don't validate that.\n */\n private _types: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" }[] = [];\n private _mappings: { flowGraphMapping: IGLTFToFlowGraphMapping; fullOperationName: string }[] = [];\n private _staticVariables: { type: FlowGraphTypes; value: any[] }[] = [];\n private _events: InteractivityEvent[] = [];\n private _internalEventsCounter: number = 0;\n private _nodes: { blocks: ISerializedFlowGraphBlock[]; fullOperationName: string }[] = [];\n\n constructor(\n private _interactivityGraph: IKHRInteractivity_Graph,\n private _gltf: IGLTF,\n public _loader: GLTFLoader\n ) {\n // start with types\n this._parseTypes();\n // continue with declarations\n this._parseDeclarations();\n this._parseVariables();\n this._parseEvents();\n this._parseNodes();\n }\n\n public get arrays() {\n return {\n types: this._types,\n mappings: this._mappings,\n staticVariables: this._staticVariables,\n events: this._events,\n nodes: this._nodes,\n };\n }\n\n private _parseTypes() {\n if (!this._interactivityGraph.types) {\n return;\n }\n for (const type of this._interactivityGraph.types) {\n this._types.push(gltfTypeToBabylonType[type.signature]);\n }\n }\n\n private _parseDeclarations() {\n if (!this._interactivityGraph.declarations) {\n return;\n }\n for (const declaration of this._interactivityGraph.declarations) {\n // make sure we have the mapping for this operation\n const mapping = getMappingForDeclaration(declaration);\n // mapping is defined, because we generate an empty mapping if it's not found\n if (!mapping) {\n Logger.Error([\"No mapping found for declaration\", declaration]);\n throw new Error(\"Error parsing declarations\");\n }\n this._mappings.push({\n flowGraphMapping: mapping,\n fullOperationName: declaration.extension ? declaration.op + \":\" + declaration.extension : declaration.op,\n });\n }\n }\n\n private _parseVariables() {\n if (!this._interactivityGraph.variables) {\n return;\n }\n for (const variable of this._interactivityGraph.variables) {\n const parsed = this._parseVariable(variable);\n // set the default values here\n this._staticVariables.push(parsed);\n }\n }\n\n private _parseVariable(variable: IKHRInteractivity_Variable, dataTransform?: (value: any, parser: InteractivityGraphToFlowGraphParser) => any) {\n const type = this._types[variable.type];\n if (!type) {\n Logger.Error([\"No type found for variable\", variable]);\n throw new Error(\"Error parsing variables\");\n }\n if (variable.value) {\n if (variable.value.length !== type.length) {\n Logger.Error([\"Invalid value length for variable\", variable, type]);\n throw new Error(\"Error parsing variables\");\n }\n }\n const value = variable.value || [];\n if (!value.length) {\n switch (type.flowGraphType) {\n case FlowGraphTypes.Boolean:\n value.push(false);\n break;\n case FlowGraphTypes.Integer:\n value.push(0);\n break;\n case FlowGraphTypes.Number:\n value.push(NaN);\n break;\n case FlowGraphTypes.Vector2:\n value.push(NaN, NaN);\n break;\n case FlowGraphTypes.Vector3:\n value.push(NaN, NaN, NaN);\n break;\n case FlowGraphTypes.Vector4:\n case FlowGraphTypes.Matrix2D:\n case FlowGraphTypes.Quaternion:\n value.fill(NaN, 0, 4);\n break;\n case FlowGraphTypes.Matrix:\n value.fill(NaN, 0, 16);\n break;\n case FlowGraphTypes.Matrix3D:\n value.fill(NaN, 0, 9);\n break;\n default:\n break;\n }\n }\n // in case of NaN, Infinity, we need to parse the string to the object itself\n if (type.elementType === \"number\" && typeof value[0] === \"string\") {\n value[0] = parseFloat(value[0]);\n }\n return { type: type.flowGraphType, value: dataTransform ? dataTransform(value, this) : value };\n }\n\n private _parseEvents() {\n if (!this._interactivityGraph.events) {\n return;\n }\n for (const event of this._interactivityGraph.events) {\n const converted: InteractivityEvent = {\n eventId: event.id || \"internalEvent_\" + this._internalEventsCounter++,\n };\n if (event.values) {\n converted.eventData = Object.keys(event.values).map((key) => {\n const eventValue = event.values?.[key];\n if (!eventValue) {\n Logger.Error([\"No value found for event key\", key]);\n throw new Error(\"Error parsing events\");\n }\n const type = this._types[eventValue.type];\n if (!type) {\n Logger.Error([\"No type found for event value\", eventValue]);\n throw new Error(\"Error parsing events\");\n }\n const value = typeof eventValue.value !== \"undefined\" ? this._parseVariable(eventValue) : undefined;\n return {\n id: key,\n type: type.flowGraphType,\n eventData: true,\n value,\n };\n });\n }\n this._events.push(converted);\n }\n }\n\n private _parseNodes() {\n if (!this._interactivityGraph.nodes) {\n return;\n }\n for (const node of this._interactivityGraph.nodes) {\n // some validation\n if (typeof node.declaration !== \"number\") {\n Logger.Error([\"No declaration found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n const mapping = this._mappings[node.declaration];\n if (!mapping) {\n Logger.Error([\"No mapping found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n if (mapping.flowGraphMapping.validation) {\n const validationResult = mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf);\n if (!validationResult.valid) {\n throw new Error(`Error validating interactivity node ${this._interactivityGraph.declarations?.[node.declaration].op} - ${validationResult.error}`);\n }\n }\n const blocks: ISerializedFlowGraphBlock[] = [];\n // create block(s) for this node using the mapping\n for (const blockType of mapping.flowGraphMapping.blocks) {\n const block = this._getEmptyBlock(blockType, mapping.fullOperationName);\n this._parseNodeConfiguration(node, block, mapping.flowGraphMapping, blockType);\n blocks.push(block);\n }\n this._nodes.push({ blocks, fullOperationName: mapping.fullOperationName });\n }\n }\n\n private _getEmptyBlock(className: string, type: string): ISerializedFlowGraphBlock {\n const uniqueId = RandomGUID();\n const dataInputs: ISerializedFlowGraphConnection[] = [];\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\n const signalInputs: ISerializedFlowGraphConnection[] = [];\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\n const config: IFlowGraphBlockConfiguration = {};\n const metadata = {};\n return {\n uniqueId,\n className,\n dataInputs,\n dataOutputs,\n signalInputs,\n signalOutputs,\n config,\n type,\n metadata,\n };\n }\n\n private _parseNodeConfiguration(node: IKHRInteractivity_Node, block: ISerializedFlowGraphBlock, nodeMapping: IGLTFToFlowGraphMapping, blockType: FlowGraphBlockNames | string) {\n const configuration = block.config;\n if (node.configuration) {\n const keys = Object.keys(node.configuration);\n for (const key of keys) {\n const value = node.configuration?.[key];\n // value is always an array, never a number or string\n if (!value) {\n Logger.Error([\"No value found for node configuration\", key]);\n throw new Error(\"Error parsing node configuration\");\n }\n const configMapping = nodeMapping.configuration?.[key];\n const belongsToBlock = configMapping && configMapping.toBlock ? configMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;\n if (belongsToBlock) {\n // get the right name for the configuration key\n const configKey = configMapping?.name || key;\n if ((!value || typeof value.value === \"undefined\") && typeof configMapping?.defaultValue !== \"undefined\") {\n configuration[configKey] = {\n value: configMapping.defaultValue,\n };\n } else if (value.value.length >= 0) {\n // supporting int[] and int/boolean/string\n configuration[configKey] = {\n value: value.value.length === 1 ? value.value[0] : value.value,\n };\n } else {\n Logger.Warn([\"Invalid value for node configuration\", value]);\n }\n // make sure we transform the data if needed\n if (configMapping && configMapping.dataTransformer) {\n configuration[configKey].value = configMapping.dataTransformer([configuration[configKey].value], this)[0];\n }\n }\n }\n }\n }\n\n private _parseNodeConnections(context: ISerializedFlowGraphContext) {\n for (let i = 0; i < this._nodes.length; i++) {\n // get the corresponding gltf node\n const gltfNode = this._interactivityGraph.nodes?.[i];\n if (!gltfNode) {\n // should never happen but let's still check\n Logger.Error([\"No node found for interactivity node\", this._nodes[i]]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowGraphBlocks = this._nodes[i];\n const outputMapper = this._mappings[gltfNode.declaration];\n // validate\n if (!outputMapper) {\n Logger.Error([\"No mapping found for node\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowsFromGLTF = gltfNode.flows || {};\n const flowsKeys = Object.keys(flowsFromGLTF).sort(); // sorting as some operations require sorted keys\n // connect the flows\n for (const flowKey of flowsKeys) {\n const flow = flowsFromGLTF[flowKey];\n const flowMapping = outputMapper.flowGraphMapping.outputs?.flows?.[flowKey];\n const socketOutName = flowMapping?.name || flowKey;\n // create a serialized socket\n const socketOut = this._createNewSocketConnection(socketOutName, true);\n const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];\n block.signalOutputs.push(socketOut);\n // get the input node of this block\n const inputNodeId = flow.node;\n const nodeIn = this._nodes[inputNodeId];\n if (!nodeIn) {\n Logger.Error([\"No node found for input node id\", inputNodeId]);\n throw new Error(\"Error parsing node connections\");\n }\n // get the mapper for the input node - in case it mapped to multiple blocks\n const inputMapper = getMappingForFullOperationName(nodeIn.fullOperationName);\n if (!inputMapper) {\n Logger.Error([\"No mapping found for input node\", nodeIn]);\n throw new Error(\"Error parsing node connections\");\n }\n let flowInMapping = inputMapper.inputs?.flows?.[flow.socket || \"in\"];\n let arrayMapping = false;\n if (!flowInMapping) {\n for (const key in inputMapper.inputs?.flows) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n flowInMapping = inputMapper.inputs?.flows?.[key];\n }\n }\n }\n const nodeInSocketName = flowInMapping ? (arrayMapping ? flowInMapping.name.replace(\"$1\", flow.socket || \"\") : flowInMapping.name) : flow.socket || \"in\";\n const inputBlock = (flowInMapping && flowInMapping.toBlock && nodeIn.blocks.find((b) => b.className === flowInMapping.toBlock)) || nodeIn.blocks[0];\n // in all of the flow graph input connections, find the one with the same name as the socket\n let socketIn = inputBlock.signalInputs.find((s) => s.name === nodeInSocketName);\n // if the socket doesn't exist, create the input socket for the connection\n if (!socketIn) {\n socketIn = this._createNewSocketConnection(nodeInSocketName);\n inputBlock.signalInputs.push(socketIn);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n }\n // connect the values\n const valuesFromGLTF = gltfNode.values || {};\n const valuesKeys = Object.keys(valuesFromGLTF);\n for (const valueKey of valuesKeys) {\n const value = valuesFromGLTF[valueKey];\n let valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[valueKey];\n let arrayMapping = false;\n if (!valueMapping) {\n for (const key in outputMapper.flowGraphMapping.inputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[key];\n }\n }\n }\n const socketInName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", valueKey) : valueMapping.name) : valueKey;\n // create a serialized socket\n const socketIn = this._createNewSocketConnection(socketInName);\n const block = (valueMapping && valueMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === valueMapping.toBlock)) || flowGraphBlocks.blocks[0];\n block.dataInputs.push(socketIn);\n if ((value as IKHRInteractivity_Variable).value !== undefined) {\n const convertedValue = this._parseVariable(value as IKHRInteractivity_Variable, valueMapping && valueMapping.dataTransformer);\n context._connectionValues[socketIn.uniqueId] = convertedValue;\n } else if (typeof (value as IKHRInteractivity_OutputSocketReference).node !== \"undefined\") {\n const nodeOutId = (value as IKHRInteractivity_OutputSocketReference).node;\n const nodeOutSocketName = (value as IKHRInteractivity_OutputSocketReference).socket || \"value\";\n const nodeOut = this._nodes[nodeOutId];\n if (!nodeOut) {\n Logger.Error([\"No node found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n const outputMapper = getMappingForFullOperationName(nodeOut.fullOperationName);\n if (!outputMapper) {\n Logger.Error([\"No mapping found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n let valueMapping = outputMapper.outputs?.values?.[nodeOutSocketName];\n let arrayMapping = false;\n // check if there is an array mapping defined\n if (!valueMapping) {\n // search for a value mapping that has an array mapping\n for (const key in outputMapper.outputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.outputs?.values?.[key];\n }\n }\n }\n const socketOutName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", nodeOutSocketName) : valueMapping?.name) : nodeOutSocketName;\n const outBlock = (valueMapping && valueMapping.toBlock && nodeOut.blocks.find((b) => b.className === valueMapping.toBlock)) || nodeOut.blocks[0];\n let socketOut = outBlock.dataOutputs.find((s) => s.name === socketOutName);\n // if the socket doesn't exist, create it\n if (!socketOut) {\n socketOut = this._createNewSocketConnection(socketOutName, true);\n outBlock.dataOutputs.push(socketOut);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n } else {\n Logger.Error([\"Invalid value for value connection\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n }\n\n // inter block connections\n if (outputMapper.flowGraphMapping.interBlockConnectors) {\n for (const connector of outputMapper.flowGraphMapping.interBlockConnectors) {\n const input = connector.input;\n const output = connector.output;\n const isVariable = connector.isVariable;\n this._connectFlowGraphNodes(input, output, flowGraphBlocks.blocks[connector.inputBlockIndex], flowGraphBlocks.blocks[connector.outputBlockIndex], isVariable);\n }\n }\n\n if (outputMapper.flowGraphMapping.extraProcessor) {\n const declaration = this._interactivityGraph.declarations?.[gltfNode.declaration];\n if (!declaration) {\n Logger.Error([\"No declaration found for extra processor\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n flowGraphBlocks.blocks = outputMapper.flowGraphMapping.extraProcessor(\n gltfNode,\n declaration,\n outputMapper.flowGraphMapping,\n this,\n flowGraphBlocks.blocks,\n context,\n this._gltf\n );\n }\n }\n }\n\n private _createNewSocketConnection(name: string, isOutput?: boolean): ISerializedFlowGraphConnection {\n return {\n uniqueId: RandomGUID(),\n name,\n _connectionType: isOutput ? FlowGraphConnectionType.Output : FlowGraphConnectionType.Input,\n connectedPointIds: [],\n };\n }\n\n private _connectFlowGraphNodes(input: string, output: string, serializedInput: ISerializedFlowGraphBlock, serializedOutput: ISerializedFlowGraphBlock, isVariable?: boolean) {\n const inputArray = isVariable ? serializedInput.dataInputs : serializedInput.signalInputs;\n const outputArray = isVariable ? serializedOutput.dataOutputs : serializedOutput.signalOutputs;\n const inputConnection = inputArray.find((s) => s.name === input) || this._createNewSocketConnection(input);\n const outputConnection = outputArray.find((s) => s.name === output) || this._createNewSocketConnection(output, true);\n // of not found add it to the array\n if (!inputArray.find((s) => s.name === input)) {\n inputArray.push(inputConnection);\n }\n if (!outputArray.find((s) => s.name === output)) {\n outputArray.push(outputConnection);\n }\n // connect the sockets\n inputConnection.connectedPointIds.push(outputConnection.uniqueId);\n outputConnection.connectedPointIds.push(inputConnection.uniqueId);\n }\n\n public getVariableName(index: number) {\n return \"staticVariable_\" + index;\n }\n\n public serializeToFlowGraph(): ISerializedFlowGraph {\n const context: ISerializedFlowGraphContext = {\n uniqueId: RandomGUID(),\n _userVariables: {},\n _connectionValues: {},\n };\n this._parseNodeConnections(context);\n for (let i = 0; i < this._staticVariables.length; i++) {\n const variable = this._staticVariables[i];\n context._userVariables[this.getVariableName(i)] = variable;\n }\n\n const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), [] as ISerializedFlowGraphBlock[]);\n\n return {\n rightHanded: true,\n allBlocks,\n executionContexts: [context],\n };\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"interactivityGraphParser.js","sourceRoot":"","sources":["../../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAgB5C,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAE9B;IACA,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,sCAAuB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACjF,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,EAAE,SAAS,EAAE;IAClF,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EA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Content":["import type { IKHRInteractivity_Graph, IKHRInteractivity_Node, IKHRInteractivity_OutputSocketReference, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\nimport type { IGLTF } from \"../../glTFLoaderInterfaces\";\nimport type { IGLTFToFlowGraphMapping } from \"./declarationMapper\";\nimport { getMappingForDeclaration, getMappingForFullOperationName } from \"./declarationMapper\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\nimport { RandomGUID } from \"core/Misc/guid\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface InteractivityEvent {\n eventId: string;\n eventData?: {\n eventData: boolean;\n id: string;\n type: string;\n value?: any;\n }[];\n}\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const gltfTypeToBabylonType: {\n [key: string]: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" };\n} = {\n float: { length: 1, flowGraphType: FlowGraphTypes.Number, elementType: \"number\" },\n bool: { length: 1, flowGraphType: FlowGraphTypes.Boolean, elementType: \"boolean\" },\n float2: { length: 2, flowGraphType: FlowGraphTypes.Vector2, elementType: \"number\" },\n float3: { length: 3, flowGraphType: FlowGraphTypes.Vector3, elementType: \"number\" },\n float4: { length: 4, flowGraphType: FlowGraphTypes.Vector4, elementType: \"number\" },\n float4x4: { length: 16, flowGraphType: FlowGraphTypes.Matrix, elementType: \"number\" },\n float2x2: { length: 4, flowGraphType: FlowGraphTypes.Matrix2D, elementType: \"number\" },\n float3x3: { length: 9, flowGraphType: FlowGraphTypes.Matrix3D, elementType: \"number\" },\n int: { length: 1, flowGraphType: FlowGraphTypes.Integer, elementType: \"number\" },\n};\n\nexport class InteractivityGraphToFlowGraphParser {\n /**\n * Note - the graph should be rejected if the same type is defined twice.\n * We currently don't validate that.\n */\n private _types: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" }[] = [];\n private _mappings: { flowGraphMapping: IGLTFToFlowGraphMapping; fullOperationName: string }[] = [];\n private _staticVariables: { type: FlowGraphTypes; value: any[] }[] = [];\n private _events: InteractivityEvent[] = [];\n private _internalEventsCounter: number = 0;\n private _nodes: { blocks: ISerializedFlowGraphBlock[]; fullOperationName: string }[] = [];\n\n constructor(\n private _interactivityGraph: IKHRInteractivity_Graph,\n private _gltf: IGLTF,\n public _animationTargetFps: number = 60\n ) {\n // start with types\n this._parseTypes();\n // continue with declarations\n this._parseDeclarations();\n this._parseVariables();\n this._parseEvents();\n this._parseNodes();\n }\n\n public get arrays() {\n return {\n types: this._types,\n mappings: this._mappings,\n staticVariables: this._staticVariables,\n events: this._events,\n nodes: this._nodes,\n };\n }\n\n private _parseTypes() {\n if (!this._interactivityGraph.types) {\n return;\n }\n for (const type of this._interactivityGraph.types) {\n this._types.push(gltfTypeToBabylonType[type.signature]);\n }\n }\n\n private _parseDeclarations() {\n if (!this._interactivityGraph.declarations) {\n return;\n }\n for (const declaration of this._interactivityGraph.declarations) {\n // make sure we have the mapping for this operation\n const mapping = getMappingForDeclaration(declaration);\n // mapping is defined, because we generate an empty mapping if it's not found\n if (!mapping) {\n Logger.Error([\"No mapping found for declaration\", declaration]);\n throw new Error(\"Error parsing declarations\");\n }\n this._mappings.push({\n flowGraphMapping: mapping,\n fullOperationName: declaration.extension ? declaration.op + \":\" + declaration.extension : declaration.op,\n });\n }\n }\n\n private _parseVariables() {\n if (!this._interactivityGraph.variables) {\n return;\n }\n for (const variable of this._interactivityGraph.variables) {\n const parsed = this._parseVariable(variable);\n // set the default values here\n this._staticVariables.push(parsed);\n }\n }\n\n private _parseVariable(variable: IKHRInteractivity_Variable, dataTransform?: (value: any, parser: InteractivityGraphToFlowGraphParser) => any) {\n const type = this._types[variable.type];\n if (!type) {\n Logger.Error([\"No type found for variable\", variable]);\n throw new Error(\"Error parsing variables\");\n }\n if (variable.value) {\n if (variable.value.length !== type.length) {\n Logger.Error([\"Invalid value length for variable\", variable, type]);\n throw new Error(\"Error parsing variables\");\n }\n }\n const value = variable.value || [];\n if (!value.length) {\n switch (type.flowGraphType) {\n case FlowGraphTypes.Boolean:\n value.push(false);\n break;\n case FlowGraphTypes.Integer:\n value.push(0);\n break;\n case FlowGraphTypes.Number:\n value.push(NaN);\n break;\n case FlowGraphTypes.Vector2:\n value.push(NaN, NaN);\n break;\n case FlowGraphTypes.Vector3:\n value.push(NaN, NaN, NaN);\n break;\n case FlowGraphTypes.Vector4:\n case FlowGraphTypes.Matrix2D:\n case FlowGraphTypes.Quaternion:\n value.fill(NaN, 0, 4);\n break;\n case FlowGraphTypes.Matrix:\n value.fill(NaN, 0, 16);\n break;\n case FlowGraphTypes.Matrix3D:\n value.fill(NaN, 0, 9);\n break;\n default:\n break;\n }\n }\n // in case of NaN, Infinity, we need to parse the string to the object itself\n if (type.elementType === \"number\" && typeof value[0] === \"string\") {\n value[0] = parseFloat(value[0]);\n }\n return { type: type.flowGraphType, value: dataTransform ? dataTransform(value, this) : value };\n }\n\n private _parseEvents() {\n if (!this._interactivityGraph.events) {\n return;\n }\n for (const event of this._interactivityGraph.events) {\n const converted: InteractivityEvent = {\n eventId: event.id || \"internalEvent_\" + this._internalEventsCounter++,\n };\n if (event.values) {\n converted.eventData = Object.keys(event.values).map((key) => {\n const eventValue = event.values?.[key];\n if (!eventValue) {\n Logger.Error([\"No value found for event key\", key]);\n throw new Error(\"Error parsing events\");\n }\n const type = this._types[eventValue.type];\n if (!type) {\n Logger.Error([\"No type found for event value\", eventValue]);\n throw new Error(\"Error parsing events\");\n }\n const value = typeof eventValue.value !== \"undefined\" ? this._parseVariable(eventValue) : undefined;\n return {\n id: key,\n type: type.flowGraphType,\n eventData: true,\n value,\n };\n });\n }\n this._events.push(converted);\n }\n }\n\n private _parseNodes() {\n if (!this._interactivityGraph.nodes) {\n return;\n }\n for (const node of this._interactivityGraph.nodes) {\n // some validation\n if (typeof node.declaration !== \"number\") {\n Logger.Error([\"No declaration found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n const mapping = this._mappings[node.declaration];\n if (!mapping) {\n Logger.Error([\"No mapping found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n if (mapping.flowGraphMapping.validation) {\n const validationResult = mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf);\n if (!validationResult.valid) {\n throw new Error(`Error validating interactivity node ${this._interactivityGraph.declarations?.[node.declaration].op} - ${validationResult.error}`);\n }\n }\n const blocks: ISerializedFlowGraphBlock[] = [];\n // create block(s) for this node using the mapping\n for (const blockType of mapping.flowGraphMapping.blocks) {\n const block = this._getEmptyBlock(blockType, mapping.fullOperationName);\n this._parseNodeConfiguration(node, block, mapping.flowGraphMapping, blockType);\n blocks.push(block);\n }\n this._nodes.push({ blocks, fullOperationName: mapping.fullOperationName });\n }\n }\n\n private _getEmptyBlock(className: string, type: string): ISerializedFlowGraphBlock {\n const uniqueId = RandomGUID();\n const dataInputs: ISerializedFlowGraphConnection[] = [];\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\n const signalInputs: ISerializedFlowGraphConnection[] = [];\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\n const config: IFlowGraphBlockConfiguration = {};\n const metadata = {};\n return {\n uniqueId,\n className,\n dataInputs,\n dataOutputs,\n signalInputs,\n signalOutputs,\n config,\n type,\n metadata,\n };\n }\n\n private _parseNodeConfiguration(node: IKHRInteractivity_Node, block: ISerializedFlowGraphBlock, nodeMapping: IGLTFToFlowGraphMapping, blockType: FlowGraphBlockNames | string) {\n const configuration = block.config;\n if (node.configuration) {\n const keys = Object.keys(node.configuration);\n for (const key of keys) {\n const value = node.configuration?.[key];\n // value is always an array, never a number or string\n if (!value) {\n Logger.Error([\"No value found for node configuration\", key]);\n throw new Error(\"Error parsing node configuration\");\n }\n const configMapping = nodeMapping.configuration?.[key];\n const belongsToBlock = configMapping && configMapping.toBlock ? configMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;\n if (belongsToBlock) {\n // get the right name for the configuration key\n const configKey = configMapping?.name || key;\n if ((!value || typeof value.value === \"undefined\") && typeof configMapping?.defaultValue !== \"undefined\") {\n configuration[configKey] = {\n value: configMapping.defaultValue,\n };\n } else if (value.value.length >= 0) {\n // supporting int[] and int/boolean/string\n configuration[configKey] = {\n value: value.value.length === 1 ? value.value[0] : value.value,\n };\n } else {\n Logger.Warn([\"Invalid value for node configuration\", value]);\n }\n // make sure we transform the data if needed\n if (configMapping && configMapping.dataTransformer) {\n configuration[configKey].value = configMapping.dataTransformer([configuration[configKey].value], this)[0];\n }\n }\n }\n }\n }\n\n private _parseNodeConnections(context: ISerializedFlowGraphContext) {\n for (let i = 0; i < this._nodes.length; i++) {\n // get the corresponding gltf node\n const gltfNode = this._interactivityGraph.nodes?.[i];\n if (!gltfNode) {\n // should never happen but let's still check\n Logger.Error([\"No node found for interactivity node\", this._nodes[i]]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowGraphBlocks = this._nodes[i];\n const outputMapper = this._mappings[gltfNode.declaration];\n // validate\n if (!outputMapper) {\n Logger.Error([\"No mapping found for node\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowsFromGLTF = gltfNode.flows || {};\n const flowsKeys = Object.keys(flowsFromGLTF).sort(); // sorting as some operations require sorted keys\n // connect the flows\n for (const flowKey of flowsKeys) {\n const flow = flowsFromGLTF[flowKey];\n const flowMapping = outputMapper.flowGraphMapping.outputs?.flows?.[flowKey];\n const socketOutName = flowMapping?.name || flowKey;\n // create a serialized socket\n const socketOut = this._createNewSocketConnection(socketOutName, true);\n const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];\n block.signalOutputs.push(socketOut);\n // get the input node of this block\n const inputNodeId = flow.node;\n const nodeIn = this._nodes[inputNodeId];\n if (!nodeIn) {\n Logger.Error([\"No node found for input node id\", inputNodeId]);\n throw new Error(\"Error parsing node connections\");\n }\n // get the mapper for the input node - in case it mapped to multiple blocks\n const inputMapper = getMappingForFullOperationName(nodeIn.fullOperationName);\n if (!inputMapper) {\n Logger.Error([\"No mapping found for input node\", nodeIn]);\n throw new Error(\"Error parsing node connections\");\n }\n let flowInMapping = inputMapper.inputs?.flows?.[flow.socket || \"in\"];\n let arrayMapping = false;\n if (!flowInMapping) {\n for (const key in inputMapper.inputs?.flows) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n flowInMapping = inputMapper.inputs?.flows?.[key];\n }\n }\n }\n const nodeInSocketName = flowInMapping ? (arrayMapping ? flowInMapping.name.replace(\"$1\", flow.socket || \"\") : flowInMapping.name) : flow.socket || \"in\";\n const inputBlock = (flowInMapping && flowInMapping.toBlock && nodeIn.blocks.find((b) => b.className === flowInMapping.toBlock)) || nodeIn.blocks[0];\n // in all of the flow graph input connections, find the one with the same name as the socket\n let socketIn = inputBlock.signalInputs.find((s) => s.name === nodeInSocketName);\n // if the socket doesn't exist, create the input socket for the connection\n if (!socketIn) {\n socketIn = this._createNewSocketConnection(nodeInSocketName);\n inputBlock.signalInputs.push(socketIn);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n }\n // connect the values\n const valuesFromGLTF = gltfNode.values || {};\n const valuesKeys = Object.keys(valuesFromGLTF);\n for (const valueKey of valuesKeys) {\n const value = valuesFromGLTF[valueKey];\n let valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[valueKey];\n let arrayMapping = false;\n if (!valueMapping) {\n for (const key in outputMapper.flowGraphMapping.inputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[key];\n }\n }\n }\n const socketInName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", valueKey) : valueMapping.name) : valueKey;\n // create a serialized socket\n const socketIn = this._createNewSocketConnection(socketInName);\n const block = (valueMapping && valueMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === valueMapping.toBlock)) || flowGraphBlocks.blocks[0];\n block.dataInputs.push(socketIn);\n if ((value as IKHRInteractivity_Variable).value !== undefined) {\n const convertedValue = this._parseVariable(value as IKHRInteractivity_Variable, valueMapping && valueMapping.dataTransformer);\n context._connectionValues[socketIn.uniqueId] = convertedValue;\n } else if (typeof (value as IKHRInteractivity_OutputSocketReference).node !== \"undefined\") {\n const nodeOutId = (value as IKHRInteractivity_OutputSocketReference).node;\n const nodeOutSocketName = (value as IKHRInteractivity_OutputSocketReference).socket || \"value\";\n const nodeOut = this._nodes[nodeOutId];\n if (!nodeOut) {\n Logger.Error([\"No node found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n const outputMapper = getMappingForFullOperationName(nodeOut.fullOperationName);\n if (!outputMapper) {\n Logger.Error([\"No mapping found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n let valueMapping = outputMapper.outputs?.values?.[nodeOutSocketName];\n let arrayMapping = false;\n // check if there is an array mapping defined\n if (!valueMapping) {\n // search for a value mapping that has an array mapping\n for (const key in outputMapper.outputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.outputs?.values?.[key];\n }\n }\n }\n const socketOutName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", nodeOutSocketName) : valueMapping?.name) : nodeOutSocketName;\n const outBlock = (valueMapping && valueMapping.toBlock && nodeOut.blocks.find((b) => b.className === valueMapping.toBlock)) || nodeOut.blocks[0];\n let socketOut = outBlock.dataOutputs.find((s) => s.name === socketOutName);\n // if the socket doesn't exist, create it\n if (!socketOut) {\n socketOut = this._createNewSocketConnection(socketOutName, true);\n outBlock.dataOutputs.push(socketOut);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n } else {\n Logger.Error([\"Invalid value for value connection\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n }\n\n // inter block connections\n if (outputMapper.flowGraphMapping.interBlockConnectors) {\n for (const connector of outputMapper.flowGraphMapping.interBlockConnectors) {\n const input = connector.input;\n const output = connector.output;\n const isVariable = connector.isVariable;\n this._connectFlowGraphNodes(input, output, flowGraphBlocks.blocks[connector.inputBlockIndex], flowGraphBlocks.blocks[connector.outputBlockIndex], isVariable);\n }\n }\n\n if (outputMapper.flowGraphMapping.extraProcessor) {\n const declaration = this._interactivityGraph.declarations?.[gltfNode.declaration];\n if (!declaration) {\n Logger.Error([\"No declaration found for extra processor\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n flowGraphBlocks.blocks = outputMapper.flowGraphMapping.extraProcessor(\n gltfNode,\n declaration,\n outputMapper.flowGraphMapping,\n this,\n flowGraphBlocks.blocks,\n context,\n this._gltf\n );\n }\n }\n }\n\n private _createNewSocketConnection(name: string, isOutput?: boolean): ISerializedFlowGraphConnection {\n return {\n uniqueId: RandomGUID(),\n name,\n _connectionType: isOutput ? FlowGraphConnectionType.Output : FlowGraphConnectionType.Input,\n connectedPointIds: [],\n };\n }\n\n private _connectFlowGraphNodes(input: string, output: string, serializedInput: ISerializedFlowGraphBlock, serializedOutput: ISerializedFlowGraphBlock, isVariable?: boolean) {\n const inputArray = isVariable ? serializedInput.dataInputs : serializedInput.signalInputs;\n const outputArray = isVariable ? serializedOutput.dataOutputs : serializedOutput.signalOutputs;\n const inputConnection = inputArray.find((s) => s.name === input) || this._createNewSocketConnection(input);\n const outputConnection = outputArray.find((s) => s.name === output) || this._createNewSocketConnection(output, true);\n // of not found add it to the array\n if (!inputArray.find((s) => s.name === input)) {\n inputArray.push(inputConnection);\n }\n if (!outputArray.find((s) => s.name === output)) {\n outputArray.push(outputConnection);\n }\n // connect the sockets\n inputConnection.connectedPointIds.push(outputConnection.uniqueId);\n outputConnection.connectedPointIds.push(inputConnection.uniqueId);\n }\n\n public getVariableName(index: number) {\n return \"staticVariable_\" + index;\n }\n\n public serializeToFlowGraph(): ISerializedFlowGraph {\n const context: ISerializedFlowGraphContext = {\n uniqueId: RandomGUID(),\n _userVariables: {},\n _connectionValues: {},\n };\n this._parseNodeConnections(context);\n for (let i = 0; i < this._staticVariables.length; i++) {\n const variable = this._staticVariables[i];\n context._userVariables[this.getVariableName(i)] = variable;\n }\n\n const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), [] as ISerializedFlowGraphBlock[]);\n\n return {\n rightHanded: true,\n allBlocks,\n executionContexts: [context],\n };\n }\n}\n"]}
|
@@ -48,7 +48,7 @@ export class KHR_interactivity {
|
|
48
48
|
const coordinator = new FlowGraphCoordinator({ scene });
|
49
49
|
coordinator.dispatchEventsSynchronously = false; // glTF interactivity dispatches events asynchronously
|
50
50
|
const graphs = interactivityDefinition.graphs.map((graph) => {
|
51
|
-
const parser = new InteractivityGraphToFlowGraphParser(graph, this._loader.gltf, this._loader);
|
51
|
+
const parser = new InteractivityGraphToFlowGraphParser(graph, this._loader.gltf, this._loader.parent.targetFps);
|
52
52
|
return parser.serializeToFlowGraph();
|
53
53
|
});
|
54
54
|
// parse each graph async
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_interactivity.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,0DAA4C;AAC3E,OAAO,EAAE,mBAAmB,EAAE,qDAAuC;AACrE,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,EAAE,sBAAsB,EAAE,w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AAE,2BAA2B,EAAE,KAAK,IAAI,EAAE;IAC5D,OAAO,CAAC,MAAM,MAAM,CAAC,+CAA+C,CAAC,CAAC,CAAC,yBAAyB,CAAC;AACrG,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity } from \"babylonjs-gltf2interface\";\r\nimport type { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\nimport { ParseFlowGraphAsync } from \"core/FlowGraph/flowGraphParser\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport type { GLTFPathToObjectConverter } from \"./gltfPathToObjectConverter\";\r\nimport { AddObjectAccessorToKey, GetPathToObjectConverter } from \"./objectModelMapping\";\r\nimport { InteractivityGraphToFlowGraphParser } from \"./KHR_interactivity/interactivityGraphParser\";\r\nimport { addToBlockFactory } from \"core/FlowGraph/Blocks/flowGraphBlockFactory\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { IAnimation } from \"../glTFLoaderInterfaces\";\r\n\r\nconst NAME = \"KHR_interactivity\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_interactivity extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_interactivity\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * Loader extension for KHR_interactivity\r\n */\r\nexport class KHR_interactivity implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _pathConverter?: GLTFPathToObjectConverter<any, any, any>;\r\n\r\n /**\r\n * @internal\r\n * @param _loader\r\n */\r\n constructor(private _loader: GLTFLoader) {\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n this._pathConverter = GetPathToObjectConverter(this._loader.gltf);\r\n // avoid starting animations automatically.\r\n _loader._skipStartAnimationStep = true;\r\n\r\n // Update object model with new pointers\r\n\r\n const scene = _loader.babylonScene;\r\n if (scene) {\r\n _AddInteractivityObjectModel(scene);\r\n }\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._pathConverter;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n if (!this._loader.babylonScene || !this._pathConverter) {\r\n return;\r\n }\r\n const scene = this._loader.babylonScene;\r\n const interactivityDefinition = this._loader.gltf.extensions?.KHR_interactivity as IKHRInteractivity;\r\n if (!interactivityDefinition) {\r\n // This can technically throw, but it's not a critical error\r\n return;\r\n }\r\n\r\n const coordinator = new FlowGraphCoordinator({ scene });\r\n coordinator.dispatchEventsSynchronously = false; // glTF interactivity dispatches events asynchronously\r\n const graphs = interactivityDefinition.graphs.map((graph) => {\r\n const parser = new InteractivityGraphToFlowGraphParser(graph, this._loader.gltf, this._loader);\r\n return parser.serializeToFlowGraph();\r\n });\r\n // parse each graph async\r\n await Promise.all(graphs.map(async (graph) => await ParseFlowGraphAsync(graph, { coordinator, pathConverter: this._pathConverter })));\r\n\r\n coordinator.start();\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * populates the object model with the interactivity extension\r\n */\r\nexport function _AddInteractivityObjectModel(scene: Scene) {\r\n // Note - all of those are read-only, as per the specs!\r\n\r\n // active camera rotation\r\n AddObjectAccessorToKey(\"/extensions/KHR_interactivity/?/activeCamera/rotation\", {\r\n get: () => {\r\n if (!scene.activeCamera) {\r\n return new Quaternion(NaN, NaN, NaN, NaN);\r\n }\r\n const quat = Quaternion.FromRotationMatrix(scene.activeCamera.getWorldMatrix()).normalize();\r\n if (!scene.useRightHandedSystem) {\r\n quat.w *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n quat.x *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n }\r\n return quat;\r\n },\r\n type: \"Quaternion\",\r\n getTarget: () => scene.activeCamera,\r\n });\r\n // activeCamera position\r\n AddObjectAccessorToKey(\"/extensions/KHR_interactivity/?/activeCamera/position\", {\r\n get: () => {\r\n if (!scene.activeCamera) {\r\n return new Vector3(NaN, NaN, NaN);\r\n }\r\n const pos = scene.activeCamera.getWorldMatrix().getTranslation(); // not global position\r\n if (!scene.useRightHandedSystem) {\r\n pos.x *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n }\r\n return pos;\r\n },\r\n type: \"Vector3\",\r\n getTarget: () => scene.activeCamera,\r\n });\r\n\r\n // /animations/{} pointers:\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/isPlaying\", {\r\n get: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup?.isPlaying ?? false;\r\n },\r\n type: \"boolean\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/minTime\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.from ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/maxTime\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.to ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n // playhead\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/playhead\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n //virtualPlayhead - TODO, do we support this property in our animations? getCurrentFrame is the only method we have for this.\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/virtualPlayhead\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n}\r\n\r\n// Register flow graph blocks. Do it here so they are available when the extension is enabled.\r\naddToBlockFactory(NAME, \"FlowGraphGLTFDataProvider\", async () => {\r\n return (await import(\"./KHR_interactivity/flowGraphGLTFDataProvider\")).FlowGraphGLTFDataProvider;\r\n});\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_interactivity(loader));\r\n"]}
|
1
|
+
{"version":3,"file":"KHR_interactivity.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,0DAA4C;AAC3E,OAAO,EAAE,mBAAmB,EAAE,qDAAuC;AACrE,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,mCAAmC,EAAE,MAA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AO,CAAC,MAAM,MAAM,CAAC,+CAA+C,CAAC,CAAC,CAAC,yBAAyB,CAAC;AACrG,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity } from \"babylonjs-gltf2interface\";\r\nimport type { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\nimport { ParseFlowGraphAsync } from \"core/FlowGraph/flowGraphParser\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport type { GLTFPathToObjectConverter } from \"./gltfPathToObjectConverter\";\r\nimport { AddObjectAccessorToKey, GetPathToObjectConverter } from \"./objectModelMapping\";\r\nimport { InteractivityGraphToFlowGraphParser } from \"./KHR_interactivity/interactivityGraphParser\";\r\nimport { addToBlockFactory } from \"core/FlowGraph/Blocks/flowGraphBlockFactory\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { IAnimation } from \"../glTFLoaderInterfaces\";\r\n\r\nconst NAME = \"KHR_interactivity\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_interactivity extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_interactivity\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * Loader extension for KHR_interactivity\r\n */\r\nexport class KHR_interactivity implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _pathConverter?: GLTFPathToObjectConverter<any, any, any>;\r\n\r\n /**\r\n * @internal\r\n * @param _loader\r\n */\r\n constructor(private _loader: GLTFLoader) {\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n this._pathConverter = GetPathToObjectConverter(this._loader.gltf);\r\n // avoid starting animations automatically.\r\n _loader._skipStartAnimationStep = true;\r\n\r\n // Update object model with new pointers\r\n\r\n const scene = _loader.babylonScene;\r\n if (scene) {\r\n _AddInteractivityObjectModel(scene);\r\n }\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._pathConverter;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n if (!this._loader.babylonScene || !this._pathConverter) {\r\n return;\r\n }\r\n const scene = this._loader.babylonScene;\r\n const interactivityDefinition = this._loader.gltf.extensions?.KHR_interactivity as IKHRInteractivity;\r\n if (!interactivityDefinition) {\r\n // This can technically throw, but it's not a critical error\r\n return;\r\n }\r\n\r\n const coordinator = new FlowGraphCoordinator({ scene });\r\n coordinator.dispatchEventsSynchronously = false; // glTF interactivity dispatches events asynchronously\r\n const graphs = interactivityDefinition.graphs.map((graph) => {\r\n const parser = new InteractivityGraphToFlowGraphParser(graph, this._loader.gltf, this._loader.parent.targetFps);\r\n return parser.serializeToFlowGraph();\r\n });\r\n // parse each graph async\r\n await Promise.all(graphs.map(async (graph) => await ParseFlowGraphAsync(graph, { coordinator, pathConverter: this._pathConverter })));\r\n\r\n coordinator.start();\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * populates the object model with the interactivity extension\r\n */\r\nexport function _AddInteractivityObjectModel(scene: Scene) {\r\n // Note - all of those are read-only, as per the specs!\r\n\r\n // active camera rotation\r\n AddObjectAccessorToKey(\"/extensions/KHR_interactivity/?/activeCamera/rotation\", {\r\n get: () => {\r\n if (!scene.activeCamera) {\r\n return new Quaternion(NaN, NaN, NaN, NaN);\r\n }\r\n const quat = Quaternion.FromRotationMatrix(scene.activeCamera.getWorldMatrix()).normalize();\r\n if (!scene.useRightHandedSystem) {\r\n quat.w *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n quat.x *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n }\r\n return quat;\r\n },\r\n type: \"Quaternion\",\r\n getTarget: () => scene.activeCamera,\r\n });\r\n // activeCamera position\r\n AddObjectAccessorToKey(\"/extensions/KHR_interactivity/?/activeCamera/position\", {\r\n get: () => {\r\n if (!scene.activeCamera) {\r\n return new Vector3(NaN, NaN, NaN);\r\n }\r\n const pos = scene.activeCamera.getWorldMatrix().getTranslation(); // not global position\r\n if (!scene.useRightHandedSystem) {\r\n pos.x *= -1; // glTF uses right-handed system, while babylon uses left-handed\r\n }\r\n return pos;\r\n },\r\n type: \"Vector3\",\r\n getTarget: () => scene.activeCamera,\r\n });\r\n\r\n // /animations/{} pointers:\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/isPlaying\", {\r\n get: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup?.isPlaying ?? false;\r\n },\r\n type: \"boolean\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/minTime\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.from ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/maxTime\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.to ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n // playhead\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/playhead\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n //virtualPlayhead - TODO, do we support this property in our animations? getCurrentFrame is the only method we have for this.\r\n AddObjectAccessorToKey(\"/animations/{}/extensions/KHR_interactivity/virtualPlayhead\", {\r\n get: (animation: IAnimation) => {\r\n return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion\r\n },\r\n type: \"number\",\r\n getTarget: (animation: IAnimation) => {\r\n return animation._babylonAnimationGroup;\r\n },\r\n });\r\n}\r\n\r\n// Register flow graph blocks. Do it here so they are available when the extension is enabled.\r\naddToBlockFactory(NAME, \"FlowGraphGLTFDataProvider\", async () => {\r\n return (await import(\"./KHR_interactivity/flowGraphGLTFDataProvider\")).FlowGraphGLTFDataProvider;\r\n});\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_interactivity(loader));\r\n"]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
2
|
import { GLTFLoader } from "../glTFLoader.js";
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
4
5
|
import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
|
5
6
|
const NAME = "KHR_materials_specular";
|
6
7
|
/**
|
@@ -36,6 +37,15 @@ export class KHR_materials_specular {
|
|
36
37
|
const promises = new Array();
|
37
38
|
promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
38
39
|
promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
|
40
|
+
// Handle the EXT_materials_specular_edge_color sub-extension
|
41
|
+
// https://github.com/KhronosGroup/glTF/blob/2a1111b88f052cbd3e2d82abb9faee56e7494904/extensions/2.0/Vendor/EXT_materials_specular_edge_color/README.md
|
42
|
+
if (extension.extensions && extension.extensions.EXT_materials_specular_edge_color && babylonMaterial instanceof PBRMaterial) {
|
43
|
+
const specularEdgeColorExtension = extension.extensions.EXT_materials_specular_edge_color;
|
44
|
+
if (specularEdgeColorExtension.specularEdgeColorEnabled) {
|
45
|
+
babylonMaterial.brdf.dielectricSpecularModel = Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR;
|
46
|
+
babylonMaterial.brdf.conductorSpecularModel = Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR;
|
47
|
+
}
|
48
|
+
}
|
39
49
|
// eslint-disable-next-line github/no-then
|
40
50
|
return await Promise.all(promises).then(() => { });
|
41
51
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;
|
1
|
+
{"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,SAAS,EAAE,6CAA+B;AAEnD,OAAO,EAAE,qBA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A6C,GAAG,IAAI,CAAC;YACzE,CAAC,CAAC,CACL,CAAC;QACN,CAAC;QAED,IAAI,UAAU,CAAC,oBAAoB,EAAE,CAAC;YAClC,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE;gBAC9G,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,mBAAmB,CAAC;gBAC1D,eAAe,CAAC,kBAAkB,GAAG,OAAO,CAAC;YACjD,CAAC,CAAC,CACL,CAAC;QACN,CAAC;QAED,0CAA0C;QAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { IEXTMaterialsSpecularEdgeColor, IKHRMaterialsSpecular } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_specular extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_specular\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_specular implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSpecular>(context, material, this.name, async (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n // Handle the EXT_materials_specular_edge_color sub-extension\r\n // https://github.com/KhronosGroup/glTF/blob/2a1111b88f052cbd3e2d82abb9faee56e7494904/extensions/2.0/Vendor/EXT_materials_specular_edge_color/README.md\r\n if (extension.extensions && extension.extensions.EXT_materials_specular_edge_color && babylonMaterial instanceof PBRMaterial) {\r\n const specularEdgeColorExtension = extension.extensions.EXT_materials_specular_edge_color as IEXTMaterialsSpecularEdgeColor;\r\n if (specularEdgeColorExtension.specularEdgeColorEnabled) {\r\n babylonMaterial.brdf.dielectricSpecularModel = Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR;\r\n babylonMaterial.brdf.conductorSpecularModel = Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR;\r\n }\r\n }\r\n // eslint-disable-next-line github/no-then\r\n return await Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _loadSpecularPropertiesAsync(context: string, properties: IKHRMaterialsSpecular, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (properties.specularFactor !== undefined) {\r\n babylonMaterial.metallicF0Factor = properties.specularFactor;\r\n }\r\n\r\n if (properties.specularColorFactor !== undefined) {\r\n babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);\r\n }\r\n\r\n if (properties.specularTexture) {\r\n (properties.specularTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular)`;\r\n babylonMaterial.metallicReflectanceTexture = texture;\r\n babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular Color)`;\r\n babylonMaterial.reflectanceTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_specular(loader));\r\n"]}
|
package/glTF/2.0/glTFLoader.js
CHANGED
@@ -1223,8 +1223,8 @@ export class GLTFLoader {
|
|
1223
1223
|
babylonCamera._parentContainer = this._assetContainer;
|
1224
1224
|
this._babylonScene._blockEntityCollection = false;
|
1225
1225
|
camera._babylonCamera = babylonCamera;
|
1226
|
-
//
|
1227
|
-
babylonCamera.
|
1226
|
+
// glTF cameras look towards the local -Z axis.
|
1227
|
+
babylonCamera.setTarget(new Vector3(0, 0, -1));
|
1228
1228
|
switch (camera.type) {
|
1229
1229
|
case "perspective" /* CameraType.PERSPECTIVE */: {
|
1230
1230
|
const perspective = camera.perspective;
|