1 |
- {"ast":null,"code":"import { EParameterType, ETextureFilterType, ECullingType, EBlendingFunction, EShaderType } from \"./glTFLoaderInterfaces.js\";\nimport { Quaternion, Vector3, Matrix } from \"@babylonjs/core/Maths/math.vector.js\";\nimport { Color3 } from \"@babylonjs/core/Maths/math.color.js\";\nimport { Tools } from \"@babylonjs/core/Misc/tools.js\";\nimport { Camera } from \"@babylonjs/core/Cameras/camera.js\";\nimport { FreeCamera } from \"@babylonjs/core/Cameras/freeCamera.js\";\nimport { Animation } from \"@babylonjs/core/Animations/animation.js\";\nimport { Bone } from \"@babylonjs/core/Bones/bone.js\";\nimport { Skeleton } from \"@babylonjs/core/Bones/skeleton.js\";\nimport { Effect } from \"@babylonjs/core/Materials/effect.js\";\nimport { Material } from \"@babylonjs/core/Materials/material.js\";\nimport { MultiMaterial } from \"@babylonjs/core/Materials/multiMaterial.js\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial.js\";\nimport { ShaderMaterial } from \"@babylonjs/core/Materials/shaderMaterial.js\";\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture.js\";\nimport { VertexData } from \"@babylonjs/core/Meshes/mesh.vertexData.js\";\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer.js\";\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry.js\";\nimport { SubMesh } from \"@babylonjs/core/Meshes/subMesh.js\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh.js\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh.js\";\nimport { HemisphericLight } from \"@babylonjs/core/Lights/hemisphericLight.js\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight.js\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight.js\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight.js\";\nimport { GLTFUtils } from \"./glTFLoaderUtils.js\";\nimport { GLTFFileLoader } from \"../glTFFileLoader.js\";\nimport { Constants } from \"@babylonjs/core/Engines/constants.js\";\n/**\n * Tokenizer. Used for shaders compatibility\n * Automatically map world, view, projection, worldViewProjection, attributes and so on\n */\nvar ETokenType;\n(function (ETokenType) {\n ETokenType[ETokenType[\"IDENTIFIER\"] = 1] = \"IDENTIFIER\";\n ETokenType[ETokenType[\"UNKNOWN\"] = 2] = \"UNKNOWN\";\n ETokenType[ETokenType[\"END_OF_INPUT\"] = 3] = \"END_OF_INPUT\";\n})(ETokenType || (ETokenType = {}));\nclass Tokenizer {\n constructor(toParse) {\n this._pos = 0;\n this.currentToken = ETokenType.UNKNOWN;\n this.currentIdentifier = \"\";\n this.currentString = \"\";\n this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/;\n this._toParse = toParse;\n this._maxPos = toParse.length;\n }\n getNextToken() {\n if (this.isEnd()) {\n return ETokenType.END_OF_INPUT;\n }\n this.currentString = this.read();\n this.currentToken = ETokenType.UNKNOWN;\n if (this.currentString === \"_\" || this.isLetterOrDigitPattern.test(this.currentString)) {\n this.currentToken = ETokenType.IDENTIFIER;\n this.currentIdentifier = this.currentString;\n while (!this.isEnd() && (this.isLetterOrDigitPattern.test(this.currentString = this.peek()) || this.currentString === \"_\")) {\n this.currentIdentifier += this.currentString;\n this.forward();\n }\n }\n return this.currentToken;\n }\n peek() {\n return this._toParse[this._pos];\n }\n read() {\n return this._toParse[this._pos++];\n }\n forward() {\n this._pos++;\n }\n isEnd() {\n return this._pos >= this._maxPos;\n }\n}\n/**\n * Values\n */\nconst glTFTransforms = [\"MODEL\", \"VIEW\", \"PROJECTION\", \"MODELVIEW\", \"MODELVIEWPROJECTION\", \"JOINTMATRIX\"];\nconst babylonTransforms = [\"world\", \"view\", \"projection\", \"worldView\", \"worldViewProjection\", \"mBones\"];\nconst glTFAnimationPaths = [\"translation\", \"rotation\", \"scale\"];\nconst babylonAnimationPaths = [\"position\", \"rotationQuaternion\", \"scaling\"];\n/**\n * Parse\n * @param parsedBuffers\n * @param gltfRuntime\n */\nconst parseBuffers = (parsedBuffers, gltfRuntime) => {\n for (const buf in parsedBuffers) {\n const parsedBuffer = parsedBuffers[buf];\n gltfRuntime.buffers[buf] = parsedBuffer;\n gltfRuntime.buffersCount++;\n }\n};\nconst parseShaders = (parsedShaders, gltfRuntime) => {\n for (const sha in parsedShaders) {\n const parsedShader = parsedShaders[sha];\n gltfRuntime.shaders[sha] = parsedShader;\n gltfRuntime.shaderscount++;\n }\n};\nconst parseObject = (parsedObjects, runtimeProperty, gltfRuntime) => {\n for (const object in parsedObjects) {\n const parsedObject = parsedObjects[object];\n gltfRuntime[runtimeProperty][object] = parsedObject;\n }\n};\n/**\n * Utils\n * @param buffer\n */\nconst normalizeUVs = buffer => {\n if (!buffer) {\n return;\n }\n for (let i = 0; i < buffer.length / 2; i++) {\n buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];\n }\n};\nconst getAttribute = attributeParameter => {\n if (attributeParameter.semantic === \"NORMAL\") {\n return \"normal\";\n } else if (attributeParameter.semantic === \"POSITION\") {\n return \"position\";\n } else if (attributeParameter.semantic === \"JOINT\") {\n return \"matricesIndices\";\n } else if (attributeParameter.semantic === \"WEIGHT\") {\n return \"matricesWeights\";\n } else if (attributeParameter.semantic === \"COLOR\") {\n return \"color\";\n } else if (attributeParameter.semantic && attributeParameter.semantic.indexOf(\"TEXCOORD_\") !== -1) {\n const channel = Number(attributeParameter.semantic.split(\"_\")[1]);\n return \"uv\" + (channel === 0 ? \"\" : channel + 1);\n }\n return null;\n};\n/**\n * Loads and creates animations\n * @param gltfRuntime\n */\nconst loadAnimations = gltfRuntime => {\n for (const anim in gltfRuntime.animations) {\n const animation = gltfRuntime.animations[anim];\n if (!animation.channels || !animation.samplers) {\n continue;\n }\n let lastAnimation = null;\n for (let i = 0; i < animation.channels.length; i++) {\n // Get parameters and load buffers\n const channel = animation.channels[i];\n const sampler = animation.samplers[channel.sampler];\n if (!sampler) {\n continue;\n }\n let inputData = null;\n let outputData = null;\n if (animation.parameters) {\n inputData = animation.parameters[sampler.input];\n outputData = animation.parameters[sampler.output];\n } else {\n inputData = sampler.input;\n outputData = sampler.output;\n }\n const bufferInput = GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]);\n const bufferOutput = GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]);\n const targetId = channel.target.id;\n let targetNode = gltfRuntime.scene.getNodeById(targetId);\n if (targetNode === null) {\n targetNode = gltfRuntime.scene.getNodeByName(targetId);\n }\n if (targetNode === null) {\n Tools.Warn(\"Creating animation named \" + anim + \". But cannot find node named \" + targetId + \" to attach to\");\n continue;\n }\n const isBone = targetNode instanceof Bone;\n // Get target path (position, rotation or scaling)\n let targetPath = channel.target.path;\n const targetPathIndex = glTFAnimationPaths.indexOf(targetPath);\n if (targetPathIndex !== -1) {\n targetPath = babylonAnimationPaths[targetPathIndex];\n }\n // Determine animation type\n let animationType = Animation.ANIMATIONTYPE_MATRIX;\n if (!isBone) {\n if (targetPath === \"rotationQuaternion\") {\n animationType = Animation.ANIMATIONTYPE_QUATERNION;\n targetNode.rotationQuaternion = new Quaternion();\n } else {\n animationType = Animation.ANIMATIONTYPE_VECTOR3;\n }\n }\n // Create animation and key frames\n let babylonAnimation = null;\n const keys = [];\n let arrayOffset = 0;\n let modifyKey = false;\n if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) {\n babylonAnimation = lastAnimation;\n modifyKey = true;\n }\n if (!modifyKey) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n babylonAnimation = new Animation(anim, isBone ? \"_matrix\" : targetPath, 1, animationType, Animation.ANIMATIONLOOPMODE_CYCLE);\n gltfRuntime.scene._blockEntityCollection = false;\n }\n // For each frame\n for (let j = 0; j < bufferInput.length; j++) {\n let value = null;\n if (targetPath === \"rotationQuaternion\") {\n // VEC4\n value = Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);\n arrayOffset += 4;\n } else {\n // Position and scaling are VEC3\n value = Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);\n arrayOffset += 3;\n }\n if (isBone) {\n const bone = targetNode;\n let translation = Vector3.Zero();\n let rotationQuaternion = new Quaternion();\n let scaling = Vector3.Zero();\n // Warning on decompose\n let mat = bone.getBaseMatrix();\n if (modifyKey && lastAnimation) {\n mat = lastAnimation.getKeys()[j].value;\n }\n mat.decompose(scaling, rotationQuaternion, translation);\n if (targetPath === \"position\") {\n translation = value;\n } else if (targetPath === \"rotationQuaternion\") {\n rotationQuaternion = value;\n } else {\n scaling = value;\n }\n value = Matrix.Compose(scaling, rotationQuaternion, translation);\n }\n if (!modifyKey) {\n keys.push({\n frame: bufferInput[j],\n value: value\n });\n } else if (lastAnimation) {\n lastAnimation.getKeys()[j].value = value;\n }\n }\n // Finish\n if (!modifyKey && babylonAnimation) {\n babylonAnimation.setKeys(keys);\n targetNode.animations.push(babylonAnimation);\n }\n lastAnimation = babylonAnimation;\n gltfRuntime.scene.stopAnimation(targetNode);\n gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);\n }\n }\n};\n/**\n * @returns the bones transformation matrix\n * @param node\n */\nconst configureBoneTransformation = node => {\n let mat = null;\n if (node.translation || node.rotation || node.scale) {\n const scale = Vector3.FromArray(node.scale || [1, 1, 1]);\n const rotation = Quaternion.FromArray(node.rotation || [0, 0, 0, 1]);\n const position = Vector3.FromArray(node.translation || [0, 0, 0]);\n mat = Matrix.Compose(scale, rotation, position);\n } else {\n mat = Matrix.FromArray(node.matrix);\n }\n return mat;\n};\n/**\n * Returns the parent bone\n * @param gltfRuntime\n * @param skins\n * @param jointName\n * @param newSkeleton\n * @returns the parent bone\n */\nconst getParentBone = (gltfRuntime, skins, jointName, newSkeleton) => {\n // Try to find\n for (let i = 0; i < newSkeleton.bones.length; i++) {\n if (newSkeleton.bones[i].name === jointName) {\n return newSkeleton.bones[i];\n }\n }\n // Not found, search in gltf nodes\n const nodes = gltfRuntime.nodes;\n for (const nde in nodes) {\n const node = nodes[nde];\n if (!node.jointName) {\n continue;\n }\n const children = node.children;\n for (let i = 0; i < children.length; i++) {\n const child = gltfRuntime.nodes[children[i]];\n if (!child.jointName) {\n continue;\n }\n if (child.jointName === jointName) {\n const mat = configureBoneTransformation(node);\n const bone = new Bone(node.name || \"\", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);\n bone.id = nde;\n return bone;\n }\n }\n }\n return null;\n};\n/**\n * Returns the appropriate root node\n * @param nodesToRoot\n * @param id\n * @returns the root node\n */\nconst getNodeToRoot = (nodesToRoot, id) => {\n for (let i = 0; i < nodesToRoot.length; i++) {\n const nodeToRoot = nodesToRoot[i];\n for (let j = 0; j < nodeToRoot.node.children.length; j++) {\n const child = nodeToRoot.node.children[j];\n if (child === id) {\n return nodeToRoot.bone;\n }\n }\n }\n return null;\n};\n/**\n * Returns the node with the joint name\n * @param gltfRuntime\n * @param jointName\n * @returns the node with the joint name\n */\nconst getJointNode = (gltfRuntime, jointName) => {\n const nodes = gltfRuntime.nodes;\n let node = nodes[jointName];\n if (node) {\n return {\n node: node,\n id: jointName\n };\n }\n for (const nde in nodes) {\n node = nodes[nde];\n if (node.jointName === jointName) {\n return {\n node: node,\n id: nde\n };\n }\n }\n return null;\n};\n/**\n * Checks if a nodes is in joints\n * @param skins\n * @param id\n * @returns true if the node is in joints, else false\n */\nconst nodeIsInJoints = (skins, id) => {\n for (let i = 0; i < skins.jointNames.length; i++) {\n if (skins.jointNames[i] === id) {\n return true;\n }\n }\n return false;\n};\n/**\n * Fills the nodes to root for bones and builds hierarchy\n * @param gltfRuntime\n * @param newSkeleton\n * @param skins\n * @param nodesToRoot\n */\nconst getNodesToRoot = (gltfRuntime, newSkeleton, skins, nodesToRoot) => {\n // Creates nodes for root\n for (const nde in gltfRuntime.nodes) {\n const node = gltfRuntime.nodes[nde];\n const id = nde;\n if (!node.jointName || nodeIsInJoints(skins, node.jointName)) {\n continue;\n }\n // Create node to root bone\n const mat = configureBoneTransformation(node);\n const bone = new Bone(node.name || \"\", newSkeleton, null, mat);\n bone.id = id;\n nodesToRoot.push({\n bone: bone,\n node: node,\n id: id\n });\n }\n // Parenting\n for (let i = 0; i < nodesToRoot.length; i++) {\n const nodeToRoot = nodesToRoot[i];\n const children = nodeToRoot.node.children;\n for (let j = 0; j < children.length; j++) {\n let child = null;\n for (let k = 0; k < nodesToRoot.length; k++) {\n if (nodesToRoot[k].id === children[j]) {\n child = nodesToRoot[k];\n break;\n }\n }\n if (child) {\n child.bone._parent = nodeToRoot.bone;\n nodeToRoot.bone.children.push(child.bone);\n }\n }\n }\n};\n/**\n * Imports a skeleton\n * @param gltfRuntime\n * @param skins\n * @param mesh\n * @param newSkeleton\n * @returns the bone name\n */\nconst importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {\n if (!newSkeleton) {\n newSkeleton = new Skeleton(skins.name || \"\", \"\", gltfRuntime.scene);\n }\n if (!skins.babylonSkeleton) {\n return newSkeleton;\n }\n // Find the root bones\n const nodesToRoot = [];\n const nodesToRootToAdd = [];\n getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);\n newSkeleton.bones = [];\n // Joints\n for (let i = 0; i < skins.jointNames.length; i++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);\n if (!jointNode) {\n continue;\n }\n const node = jointNode.node;\n if (!node) {\n Tools.Warn(\"Joint named \" + skins.jointNames[i] + \" does not exist\");\n continue;\n }\n const id = jointNode.id;\n // Optimize, if the bone already exists...\n const existingBone = gltfRuntime.scene.getBoneById(id);\n if (existingBone) {\n newSkeleton.bones.push(existingBone);\n continue;\n }\n // Search for parent bone\n let foundBone = false;\n let parentBone = null;\n for (let j = 0; j < i; j++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[j]);\n if (!jointNode) {\n continue;\n }\n const joint = jointNode.node;\n if (!joint) {\n Tools.Warn(\"Joint named \" + skins.jointNames[j] + \" does not exist when looking for parent\");\n continue;\n }\n const children = joint.children;\n if (!children) {\n continue;\n }\n foundBone = false;\n for (let k = 0; k < children.length; k++) {\n if (children[k] === id) {\n parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);\n foundBone = true;\n break;\n }\n }\n if (foundBone) {\n break;\n }\n }\n // Create bone\n const mat = configureBoneTransformation(node);\n if (!parentBone && nodesToRoot.length > 0) {\n parentBone = getNodeToRoot(nodesToRoot, id);\n if (parentBone) {\n if (nodesToRootToAdd.indexOf(parentBone) === -1) {\n nodesToRootToAdd.push(parentBone);\n }\n }\n }\n const bone = new Bone(node.jointName || \"\", newSkeleton, parentBone, mat);\n bone.id = id;\n }\n // Polish\n const bones = newSkeleton.bones;\n newSkeleton.bones = [];\n for (let i = 0; i < skins.jointNames.length; i++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);\n if (!jointNode) {\n continue;\n }\n for (let j = 0; j < bones.length; j++) {\n if (bones[j].id === jointNode.id) {\n newSkeleton.bones.push(bones[j]);\n break;\n }\n }\n }\n newSkeleton.prepare();\n // Finish\n for (let i = 0; i < nodesToRootToAdd.length; i++) {\n newSkeleton.bones.push(nodesToRootToAdd[i]);\n }\n return newSkeleton;\n};\n/**\n * Imports a mesh and its geometries\n * @param gltfRuntime\n * @param node\n * @param meshes\n * @param id\n * @param newMesh\n * @returns the new mesh\n */\nconst importMesh = (gltfRuntime, node, meshes, id, newMesh) => {\n if (!newMesh) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n newMesh = new Mesh(node.name || \"\", gltfRuntime.scene);\n newMesh._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n newMesh.id = id;\n }\n if (!node.babylonNode) {\n return newMesh;\n }\n const subMaterials = [];\n let vertexData = null;\n const verticesStarts = [];\n const verticesCounts = [];\n const indexStarts = [];\n const indexCounts = [];\n for (let meshIndex = 0; meshIndex < meshes.length; meshIndex++) {\n const meshId = meshes[meshIndex];\n const mesh = gltfRuntime.meshes[meshId];\n if (!mesh) {\n continue;\n }\n // Positions, normals and UVs\n for (let i = 0; i < mesh.primitives.length; i++) {\n // Temporary vertex data\n const tempVertexData = new VertexData();\n const primitive = mesh.primitives[i];\n if (primitive.mode !== 4) {\n // continue;\n }\n const attributes = primitive.attributes;\n let accessor = null;\n let buffer = null;\n // Set positions, normal and uvs\n for (const semantic in attributes) {\n // Link accessor and buffer view\n accessor = gltfRuntime.accessors[attributes[semantic]];\n buffer = GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);\n if (semantic === \"NORMAL\") {\n tempVertexData.normals = new Float32Array(buffer.length);\n tempVertexData.normals.set(buffer);\n } else if (semantic === \"POSITION\") {\n if (GLTFFileLoader.HomogeneousCoordinates) {\n tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);\n for (let j = 0; j < buffer.length; j += 4) {\n tempVertexData.positions[j] = buffer[j];\n tempVertexData.positions[j + 1] = buffer[j + 1];\n tempVertexData.positions[j + 2] = buffer[j + 2];\n }\n } else {\n tempVertexData.positions = new Float32Array(buffer.length);\n tempVertexData.positions.set(buffer);\n }\n verticesCounts.push(tempVertexData.positions.length);\n } else if (semantic.indexOf(\"TEXCOORD_\") !== -1) {\n const channel = Number(semantic.split(\"_\")[1]);\n const uvKind = VertexBuffer.UVKind + (channel === 0 ? \"\" : channel + 1);\n const uvs = new Float32Array(buffer.length);\n uvs.set(buffer);\n normalizeUVs(uvs);\n tempVertexData.set(uvs, uvKind);\n } else if (semantic === \"JOINT\") {\n tempVertexData.matricesIndices = new Float32Array(buffer.length);\n tempVertexData.matricesIndices.set(buffer);\n } else if (semantic === \"WEIGHT\") {\n tempVertexData.matricesWeights = new Float32Array(buffer.length);\n tempVertexData.matricesWeights.set(buffer);\n } else if (semantic === \"COLOR\") {\n tempVertexData.colors = new Float32Array(buffer.length);\n tempVertexData.colors.set(buffer);\n }\n }\n // Indices\n accessor = gltfRuntime.accessors[primitive.indices];\n if (accessor) {\n buffer = GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);\n tempVertexData.indices = new Int32Array(buffer.length);\n tempVertexData.indices.set(buffer);\n indexCounts.push(tempVertexData.indices.length);\n } else {\n // Set indices on the fly\n const indices = [];\n for (let j = 0; j < tempVertexData.positions.length / 3; j++) {\n indices.push(j);\n }\n tempVertexData.indices = new Int32Array(indices);\n indexCounts.push(tempVertexData.indices.length);\n }\n if (!vertexData) {\n vertexData = tempVertexData;\n } else {\n vertexData.merge(tempVertexData);\n }\n // Sub material\n const material = gltfRuntime.scene.getMaterialById(primitive.material);\n subMaterials.push(material === null ? GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material);\n // Update vertices start and index start\n verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);\n indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);\n }\n }\n let material;\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n if (subMaterials.length > 1) {\n material = new MultiMaterial(\"multimat\" + id, gltfRuntime.scene);\n material.subMaterials = subMaterials;\n } else {\n material = new StandardMaterial(\"multimat\" + id, gltfRuntime.scene);\n }\n if (subMaterials.length === 1) {\n material = subMaterials[0];\n }\n material._parentContainer = gltfRuntime.assetContainer;\n if (!newMesh.material) {\n newMesh.material = material;\n }\n // Apply geometry\n new Geometry(id, gltfRuntime.scene, vertexData, false, newMesh);\n newMesh.computeWorldMatrix(true);\n gltfRuntime.scene._blockEntityCollection = false;\n // Apply submeshes\n newMesh.subMeshes = [];\n let index = 0;\n for (let meshIndex = 0; meshIndex < meshes.length; meshIndex++) {\n const meshId = meshes[meshIndex];\n const mesh = gltfRuntime.meshes[meshId];\n if (!mesh) {\n continue;\n }\n for (let i = 0; i < mesh.primitives.length; i++) {\n if (mesh.primitives[i].mode !== 4) {\n //continue;\n }\n SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true);\n index++;\n }\n }\n // Finish\n return newMesh;\n};\n/**\n * Configure node transformation from position, rotation and scaling\n * @param newNode\n * @param position\n * @param rotation\n * @param scaling\n */\nconst configureNode = (newNode, position, rotation, scaling) => {\n if (newNode.position) {\n newNode.position = position;\n }\n if (newNode.rotationQuaternion || newNode.rotation) {\n newNode.rotationQuaternion = rotation;\n }\n if (newNode.scaling) {\n newNode.scaling = scaling;\n }\n};\n/**\n * Configures node from transformation matrix\n * @param newNode\n * @param node\n */\nconst configureNodeFromMatrix = (newNode, node) => {\n if (node.matrix) {\n const position = new Vector3(0, 0, 0);\n const rotation = new Quaternion();\n const scaling = new Vector3(0, 0, 0);\n const mat = Matrix.FromArray(node.matrix);\n mat.decompose(scaling, rotation, position);\n configureNode(newNode, position, rotation, scaling);\n } else if (node.translation && node.rotation && node.scale) {\n configureNode(newNode, Vector3.FromArray(node.translation), Quaternion.FromArray(node.rotation), Vector3.FromArray(node.scale));\n }\n newNode.computeWorldMatrix(true);\n};\n/**\n * Imports a node\n * @param gltfRuntime\n * @param node\n * @param id\n * @returns the newly imported node\n */\nconst importNode = (gltfRuntime, node, id) => {\n let lastNode = null;\n if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {\n if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || \"\") === -1) {\n return null;\n }\n }\n // Meshes\n if (node.skin) {\n if (node.meshes) {\n const skin = gltfRuntime.skins[node.skin];\n const newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);\n newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);\n if (newMesh.skeleton === null) {\n newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton);\n if (!skin.babylonSkeleton) {\n skin.babylonSkeleton = newMesh.skeleton;\n }\n }\n lastNode = newMesh;\n }\n } else if (node.meshes) {\n /**\n * Improve meshes property\n */\n const newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);\n lastNode = newMesh;\n }\n // Lights\n else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {\n const light = gltfRuntime.lights[node.light];\n if (light) {\n if (light.type === \"ambient\") {\n const ambienLight = light[light.type];\n const hemiLight = new HemisphericLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n hemiLight.name = node.name || \"\";\n if (ambienLight.color) {\n hemiLight.diffuse = Color3.FromArray(ambienLight.color);\n }\n lastNode = hemiLight;\n } else if (light.type === \"directional\") {\n const directionalLight = light[light.type];\n const dirLight = new DirectionalLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n dirLight.name = node.name || \"\";\n if (directionalLight.color) {\n dirLight.diffuse = Color3.FromArray(directionalLight.color);\n }\n lastNode = dirLight;\n } else if (light.type === \"point\") {\n const pointLight = light[light.type];\n const ptLight = new PointLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n ptLight.name = node.name || \"\";\n if (pointLight.color) {\n ptLight.diffuse = Color3.FromArray(pointLight.color);\n }\n lastNode = ptLight;\n } else if (light.type === \"spot\") {\n const spotLight = light[light.type];\n const spLight = new SpotLight(node.light, Vector3.Zero(), Vector3.Zero(), 0, 0, gltfRuntime.scene);\n spLight.name = node.name || \"\";\n if (spotLight.color) {\n spLight.diffuse = Color3.FromArray(spotLight.color);\n }\n if (spotLight.fallOfAngle) {\n spLight.angle = spotLight.fallOfAngle;\n }\n if (spotLight.fallOffExponent) {\n spLight.exponent = spotLight.fallOffExponent;\n }\n lastNode = spLight;\n }\n }\n }\n // Cameras\n else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {\n const camera = gltfRuntime.cameras[node.camera];\n if (camera) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n if (camera.type === \"orthographic\") {\n const orthoCamera = new FreeCamera(node.camera, Vector3.Zero(), gltfRuntime.scene, false);\n orthoCamera.name = node.name || \"\";\n orthoCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;\n orthoCamera.attachControl();\n lastNode = orthoCamera;\n orthoCamera._parentContainer = gltfRuntime.assetContainer;\n } else if (camera.type === \"perspective\") {\n const perspectiveCamera = camera[camera.type];\n const persCamera = new FreeCamera(node.camera, Vector3.Zero(), gltfRuntime.scene, false);\n persCamera.name = node.name || \"\";\n persCamera.attachControl();\n if (!perspectiveCamera.aspectRatio) {\n perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight();\n }\n if (perspectiveCamera.znear && perspectiveCamera.zfar) {\n persCamera.maxZ = perspectiveCamera.zfar;\n persCamera.minZ = perspectiveCamera.znear;\n }\n lastNode = persCamera;\n persCamera._parentContainer = gltfRuntime.assetContainer;\n }\n gltfRuntime.scene._blockEntityCollection = false;\n }\n }\n // Empty node\n if (!node.jointName) {\n if (node.babylonNode) {\n return node.babylonNode;\n } else if (lastNode === null) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n const dummy = new Mesh(node.name || \"\", gltfRuntime.scene);\n dummy._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n node.babylonNode = dummy;\n lastNode = dummy;\n }\n }\n if (lastNode !== null) {\n if (node.matrix && lastNode instanceof Mesh) {\n configureNodeFromMatrix(lastNode, node);\n } else {\n const translation = node.translation || [0, 0, 0];\n const rotation = node.rotation || [0, 0, 0, 1];\n const scale = node.scale || [1, 1, 1];\n configureNode(lastNode, Vector3.FromArray(translation), Quaternion.FromArray(rotation), Vector3.FromArray(scale));\n }\n lastNode.updateCache(true);\n node.babylonNode = lastNode;\n }\n return lastNode;\n};\n/**\n * Traverses nodes and creates them\n * @param gltfRuntime\n * @param id\n * @param parent\n * @param meshIncluded\n */\nconst traverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {\n const node = gltfRuntime.nodes[id];\n let newNode = null;\n if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {\n if (gltfRuntime.importMeshesNames.indexOf(node.name || \"\") !== -1 || gltfRuntime.importMeshesNames.length === 0) {\n meshIncluded = true;\n } else {\n meshIncluded = false;\n }\n } else {\n meshIncluded = true;\n }\n if (!node.jointName && meshIncluded) {\n newNode = importNode(gltfRuntime, node, id);\n if (newNode !== null) {\n newNode.id = id;\n newNode.parent = parent;\n }\n }\n if (node.children) {\n for (let i = 0; i < node.children.length; i++) {\n traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);\n }\n }\n};\n/**\n * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)\n * @param gltfRuntime\n */\nconst postLoad = gltfRuntime => {\n // Nodes\n let currentScene = gltfRuntime.currentScene;\n if (currentScene) {\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n } else {\n for (const thing in gltfRuntime.scenes) {\n currentScene = gltfRuntime.scenes[thing];\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n }\n // Set animations\n loadAnimations(gltfRuntime);\n for (let i = 0; i < gltfRuntime.scene.skeletons.length; i++) {\n const skeleton = gltfRuntime.scene.skeletons[i];\n gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);\n }\n};\n/**\n * onBind shaderrs callback to set uniforms and matrices\n * @param mesh\n * @param gltfRuntime\n * @param unTreatedUniforms\n * @param shaderMaterial\n * @param technique\n * @param material\n * @param onSuccess\n */\nconst onBindShaderMaterial = (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) => {\n const materialValues = material.values || technique.parameters;\n for (const unif in unTreatedUniforms) {\n const uniform = unTreatedUniforms[unif];\n const type = uniform.type;\n if (type === EParameterType.FLOAT_MAT2 || type === EParameterType.FLOAT_MAT3 || type === EParameterType.FLOAT_MAT4) {\n if (uniform.semantic && !uniform.source && !uniform.node) {\n GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect());\n } else if (uniform.semantic && (uniform.source || uniform.node)) {\n let source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || \"\");\n if (source === null) {\n source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || \"\");\n }\n if (source === null) {\n continue;\n }\n GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect());\n }\n } else {\n const value = materialValues[technique.uniforms[unif]];\n if (!value) {\n continue;\n }\n if (type === EParameterType.SAMPLER_2D) {\n const texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture;\n if (texture === null || texture === undefined) {\n continue;\n }\n shaderMaterial.getEffect().setTexture(unif, texture);\n } else {\n GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type);\n }\n }\n }\n onSuccess(shaderMaterial);\n};\n/**\n * Prepare uniforms to send the only one time\n * Loads the appropriate textures\n * @param gltfRuntime\n * @param shaderMaterial\n * @param technique\n * @param material\n */\nconst prepareShaderMaterialUniforms = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) => {\n const materialValues = material.values || technique.parameters;\n const techniqueUniforms = technique.uniforms;\n /**\n * Prepare values here (not matrices)\n */\n for (const unif in unTreatedUniforms) {\n const uniform = unTreatedUniforms[unif];\n const type = uniform.type;\n let value = materialValues[techniqueUniforms[unif]];\n if (value === undefined) {\n // In case the value is the same for all materials\n value = uniform.value;\n }\n if (!value) {\n continue;\n }\n const onLoadTexture = uniformName => {\n return texture => {\n if (uniform.value && uniformName) {\n // Static uniform\n shaderMaterial.setTexture(uniformName, texture);\n delete unTreatedUniforms[uniformName];\n }\n };\n };\n // Texture (sampler2D)\n if (type === EParameterType.SAMPLER_2D) {\n GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), () => onLoadTexture(null));\n }\n // Others\n else {\n if (uniform.value && GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) {\n // Static uniform\n delete unTreatedUniforms[unif];\n }\n }\n }\n};\n/**\n * Shader compilation failed\n * @param program\n * @param shaderMaterial\n * @param onError\n * @returns callback when shader is compiled\n */\nconst onShaderCompileError = (program, shaderMaterial, onError) => {\n return (effect, error) => {\n shaderMaterial.dispose(true);\n onError(\"Cannot compile program named \" + program.name + \". Error: \" + error + \". Default material will be applied\");\n };\n};\n/**\n * Shader compilation success\n * @param gltfRuntime\n * @param shaderMaterial\n * @param technique\n * @param material\n * @param unTreatedUniforms\n * @param onSuccess\n * @returns callback when shader is compiled\n */\nconst onShaderCompileSuccess = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) => {\n return _ => {\n prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);\n shaderMaterial.onBind = mesh => {\n onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);\n };\n };\n};\n/**\n * Returns the appropriate uniform if already handled by babylon\n * @param tokenizer\n * @param technique\n * @param unTreatedUniforms\n * @returns the name of the uniform handled by babylon\n */\nconst parseShaderUniforms = (tokenizer, technique, unTreatedUniforms) => {\n for (const unif in technique.uniforms) {\n const uniform = technique.uniforms[unif];\n const uniformParameter = technique.parameters[uniform];\n if (tokenizer.currentIdentifier === unif) {\n if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) {\n const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);\n if (transformIndex !== -1) {\n delete unTreatedUniforms[unif];\n return babylonTransforms[transformIndex];\n }\n }\n }\n }\n return tokenizer.currentIdentifier;\n};\n/**\n * All shaders loaded. Create materials one by one\n * @param gltfRuntime\n */\nconst importMaterials = gltfRuntime => {\n // Create materials\n for (const mat in gltfRuntime.materials) {\n GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, () => {}, () => {});\n }\n};\n/**\n * Implementation of the base glTF spec\n * @internal\n */\nexport class GLTFLoaderBase {\n static CreateRuntime(parsedData, scene, rootUrl) {\n const gltfRuntime = {\n extensions: {},\n accessors: {},\n buffers: {},\n bufferViews: {},\n meshes: {},\n lights: {},\n cameras: {},\n nodes: {},\n images: {},\n textures: {},\n shaders: {},\n programs: {},\n samplers: {},\n techniques: {},\n materials: {},\n animations: {},\n skins: {},\n extensionsUsed: [],\n scenes: {},\n buffersCount: 0,\n shaderscount: 0,\n scene: scene,\n rootUrl: rootUrl,\n loadedBufferCount: 0,\n loadedBufferViews: {},\n loadedShaderCount: 0,\n importOnlyMeshes: false,\n dummyNodes: [],\n assetContainer: null\n };\n // Parse\n if (parsedData.extensions) {\n parseObject(parsedData.extensions, \"extensions\", gltfRuntime);\n }\n if (parsedData.extensionsUsed) {\n parseObject(parsedData.extensionsUsed, \"extensionsUsed\", gltfRuntime);\n }\n if (parsedData.buffers) {\n parseBuffers(parsedData.buffers, gltfRuntime);\n }\n if (parsedData.bufferViews) {\n parseObject(parsedData.bufferViews, \"bufferViews\", gltfRuntime);\n }\n if (parsedData.accessors) {\n parseObject(parsedData.accessors, \"accessors\", gltfRuntime);\n }\n if (parsedData.meshes) {\n parseObject(parsedData.meshes, \"meshes\", gltfRuntime);\n }\n if (parsedData.lights) {\n parseObject(parsedData.lights, \"lights\", gltfRuntime);\n }\n if (parsedData.cameras) {\n parseObject(parsedData.cameras, \"cameras\", gltfRuntime);\n }\n if (parsedData.nodes) {\n parseObject(parsedData.nodes, \"nodes\", gltfRuntime);\n }\n if (parsedData.images) {\n parseObject(parsedData.images, \"images\", gltfRuntime);\n }\n if (parsedData.textures) {\n parseObject(parsedData.textures, \"textures\", gltfRuntime);\n }\n if (parsedData.shaders) {\n parseShaders(parsedData.shaders, gltfRuntime);\n }\n if (parsedData.programs) {\n parseObject(parsedData.programs, \"programs\", gltfRuntime);\n }\n if (parsedData.samplers) {\n parseObject(parsedData.samplers, \"samplers\", gltfRuntime);\n }\n if (parsedData.techniques) {\n parseObject(parsedData.techniques, \"techniques\", gltfRuntime);\n }\n if (parsedData.materials) {\n parseObject(parsedData.materials, \"materials\", gltfRuntime);\n }\n if (parsedData.animations) {\n parseObject(parsedData.animations, \"animations\", gltfRuntime);\n }\n if (parsedData.skins) {\n parseObject(parsedData.skins, \"skins\", gltfRuntime);\n }\n if (parsedData.scenes) {\n gltfRuntime.scenes = parsedData.scenes;\n }\n if (parsedData.scene && parsedData.scenes) {\n gltfRuntime.currentScene = parsedData.scenes[parsedData.scene];\n }\n return gltfRuntime;\n }\n static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n const buffer = gltfRuntime.buffers[id];\n if (Tools.IsBase64(buffer.uri)) {\n setTimeout(() => onSuccess(new Uint8Array(Tools.DecodeBase64(buffer.uri))));\n } else {\n Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, data => onSuccess(new Uint8Array(data)), onProgress, undefined, true, request => {\n if (request) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n const texture = gltfRuntime.textures[id];\n if (!texture || !texture.source) {\n onError(\"\");\n return;\n }\n if (texture.babylonTexture) {\n onSuccess(null);\n return;\n }\n const source = gltfRuntime.images[texture.source];\n if (Tools.IsBase64(source.uri)) {\n setTimeout(() => onSuccess(new Uint8Array(Tools.DecodeBase64(source.uri))));\n } else {\n Tools.LoadFile(gltfRuntime.rootUrl + source.uri, data => onSuccess(new Uint8Array(data)), undefined, undefined, true, request => {\n if (request) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess) {\n const texture = gltfRuntime.textures[id];\n if (texture.babylonTexture) {\n onSuccess(texture.babylonTexture);\n return;\n }\n const sampler = gltfRuntime.samplers[texture.sampler];\n const createMipMaps = sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_NEAREST || sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_LINEAR || sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_NEAREST || sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_LINEAR;\n const samplingMode = Texture.BILINEAR_SAMPLINGMODE;\n const blob = buffer == null ? new Blob() : new Blob([buffer]);\n const blobURL = URL.createObjectURL(blob);\n const revokeBlobURL = () => URL.revokeObjectURL(blobURL);\n const newTexture = new Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL);\n if (sampler.wrapS !== undefined) {\n newTexture.wrapU = GLTFUtils.GetWrapMode(sampler.wrapS);\n }\n if (sampler.wrapT !== undefined) {\n newTexture.wrapV = GLTFUtils.GetWrapMode(sampler.wrapT);\n }\n newTexture.name = id;\n texture.babylonTexture = newTexture;\n onSuccess(newTexture);\n }\n static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n const shader = gltfRuntime.shaders[id];\n if (Tools.IsBase64(shader.uri)) {\n const shaderString = atob(shader.uri.split(\",\")[1]);\n if (onSuccess) {\n onSuccess(shaderString);\n }\n } else {\n Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, request => {\n if (request && onError) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n const material = gltfRuntime.materials[id];\n if (!material.technique) {\n if (onError) {\n onError(\"No technique found.\");\n }\n return;\n }\n const technique = gltfRuntime.techniques[material.technique];\n if (!technique) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n const defaultMaterial = new StandardMaterial(id, gltfRuntime.scene);\n defaultMaterial._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n defaultMaterial.diffuseColor = new Color3(0.5, 0.5, 0.5);\n defaultMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n onSuccess(defaultMaterial);\n return;\n }\n const program = gltfRuntime.programs[technique.program];\n const states = technique.states;\n const vertexShader = Effect.ShadersStore[program.vertexShader + \"VertexShader\"];\n const pixelShader = Effect.ShadersStore[program.fragmentShader + \"PixelShader\"];\n let newVertexShader = \"\";\n let newPixelShader = \"\";\n const vertexTokenizer = new Tokenizer(vertexShader);\n const pixelTokenizer = new Tokenizer(pixelShader);\n const unTreatedUniforms = {};\n const uniforms = [];\n const attributes = [];\n const samplers = [];\n // Fill uniform, sampler2D and attributes\n for (const unif in technique.uniforms) {\n const uniform = technique.uniforms[unif];\n const uniformParameter = technique.parameters[uniform];\n unTreatedUniforms[unif] = uniformParameter;\n if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {\n const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);\n if (transformIndex !== -1) {\n uniforms.push(babylonTransforms[transformIndex]);\n delete unTreatedUniforms[unif];\n } else {\n uniforms.push(unif);\n }\n } else if (uniformParameter.type === EParameterType.SAMPLER_2D) {\n samplers.push(unif);\n } else {\n uniforms.push(unif);\n }\n }\n for (const attr in technique.attributes) {\n const attribute = technique.attributes[attr];\n const attributeParameter = technique.parameters[attribute];\n if (attributeParameter.semantic) {\n const name = getAttribute(attributeParameter);\n if (name) {\n attributes.push(name);\n }\n }\n }\n // Configure vertex shader\n while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) {\n const tokenType = vertexTokenizer.currentToken;\n if (tokenType !== ETokenType.IDENTIFIER) {\n newVertexShader += vertexTokenizer.currentString;\n continue;\n }\n let foundAttribute = false;\n for (const attr in technique.attributes) {\n const attribute = technique.attributes[attr];\n const attributeParameter = technique.parameters[attribute];\n if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {\n newVertexShader += getAttribute(attributeParameter);\n foundAttribute = true;\n break;\n }\n }\n if (foundAttribute) {\n continue;\n }\n newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);\n }\n // Configure pixel shader\n while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {\n const tokenType = pixelTokenizer.currentToken;\n if (tokenType !== ETokenType.IDENTIFIER) {\n newPixelShader += pixelTokenizer.currentString;\n continue;\n }\n newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);\n }\n // Create shader material\n const shaderPath = {\n vertex: program.vertexShader + id,\n fragment: program.fragmentShader + id\n };\n const options = {\n attributes: attributes,\n uniforms: uniforms,\n samplers: samplers,\n needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1\n };\n Effect.ShadersStore[program.vertexShader + id + \"VertexShader\"] = newVertexShader;\n Effect.ShadersStore[program.fragmentShader + id + \"PixelShader\"] = newPixelShader;\n const shaderMaterial = new ShaderMaterial(id, gltfRuntime.scene, shaderPath, options);\n shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError);\n shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);\n shaderMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n if (states && states.functions) {\n const functions = states.functions;\n if (functions.cullFace && functions.cullFace[0] !== ECullingType.BACK) {\n shaderMaterial.backFaceCulling = false;\n }\n const blendFunc = functions.blendFuncSeparate;\n if (blendFunc) {\n if (blendFunc[0] === EBlendingFunction.SRC_ALPHA && blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_ALPHA && blendFunc[2] === EBlendingFunction.ONE && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_COMBINE;\n } else if (blendFunc[0] === EBlendingFunction.ONE && blendFunc[1] === EBlendingFunction.ONE && blendFunc[2] === EBlendingFunction.ZERO && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_ONEONE;\n } else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA && blendFunc[1] === EBlendingFunction.ONE && blendFunc[2] === EBlendingFunction.ZERO && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_ADD;\n } else if (blendFunc[0] === EBlendingFunction.ZERO && blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR && blendFunc[2] === EBlendingFunction.ONE && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_SUBTRACT;\n } else if (blendFunc[0] === EBlendingFunction.DST_COLOR && blendFunc[1] === EBlendingFunction.ZERO && blendFunc[2] === EBlendingFunction.ONE && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_MULTIPLY;\n } else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA && blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR && blendFunc[2] === EBlendingFunction.ONE && blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_MAXIMIZED;\n }\n }\n }\n }\n}\n/**\n * glTF V1 Loader\n * @internal\n * @deprecated\n */\nexport class GLTFLoader {\n static RegisterExtension(extension) {\n if (GLTFLoader.Extensions[extension.name]) {\n Tools.Error('Tool with the same name \"' + extension.name + '\" already exists');\n return;\n }\n GLTFLoader.Extensions[extension.name] = extension;\n }\n dispose() {\n // do nothing\n }\n _importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) {\n scene.useRightHandedSystem = true;\n GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, gltfRuntime => {\n gltfRuntime.assetContainer = assetContainer;\n gltfRuntime.importOnlyMeshes = true;\n if (meshesNames === \"\") {\n gltfRuntime.importMeshesNames = [];\n } else if (typeof meshesNames === \"string\") {\n gltfRuntime.importMeshesNames = [meshesNames];\n } else if (meshesNames && !(meshesNames instanceof Array)) {\n gltfRuntime.importMeshesNames = [meshesNames];\n } else {\n gltfRuntime.importMeshesNames = [];\n Tools.Warn(\"Argument meshesNames must be of type string or string[]\");\n }\n // Create nodes\n this._createNodes(gltfRuntime);\n const meshes = [];\n const skeletons = [];\n // Fill arrays of meshes and skeletons\n for (const nde in gltfRuntime.nodes) {\n const node = gltfRuntime.nodes[nde];\n if (node.babylonNode instanceof AbstractMesh) {\n meshes.push(node.babylonNode);\n }\n }\n for (const skl in gltfRuntime.skins) {\n const skin = gltfRuntime.skins[skl];\n if (skin.babylonSkeleton instanceof Skeleton) {\n skeletons.push(skin.babylonSkeleton);\n }\n }\n // Load buffers, shaders, materials, etc.\n this._loadBuffersAsync(gltfRuntime, () => {\n this._loadShadersAsync(gltfRuntime, () => {\n importMaterials(gltfRuntime);\n postLoad(gltfRuntime);\n if (!GLTFFileLoader.IncrementalLoading && onSuccess) {\n onSuccess(meshes, skeletons);\n }\n });\n });\n if (GLTFFileLoader.IncrementalLoading && onSuccess) {\n onSuccess(meshes, skeletons);\n }\n }, onError);\n return true;\n }\n /**\n * Imports one or more meshes from a loaded gltf file and adds them to the scene\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\n * @param scene the scene the meshes should be added to\n * @param assetContainer defines the asset container to use (can be null)\n * @param data gltf data containing information of the meshes in a loaded file\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @returns a promise containg the loaded meshes, particles, skeletons and animations\n */\n importMeshAsync(meshesNames, scene, assetContainer, data, rootUrl, onProgress) {\n return new Promise((resolve, reject) => {\n this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, (meshes, skeletons) => {\n resolve({\n meshes: meshes,\n particleSystems: [],\n skeletons: skeletons,\n animationGroups: [],\n lights: [],\n transformNodes: [],\n geometries: [],\n spriteManagers: []\n });\n }, onProgress, message => {\n reject(new Error(message));\n });\n });\n }\n _loadAsync(scene, data, rootUrl, onSuccess, onProgress, onError) {\n scene.useRightHandedSystem = true;\n GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, gltfRuntime => {\n // Load runtime extensios\n GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, () => {\n // Create nodes\n this._createNodes(gltfRuntime);\n // Load buffers, shaders, materials, etc.\n this._loadBuffersAsync(gltfRuntime, () => {\n this._loadShadersAsync(gltfRuntime, () => {\n importMaterials(gltfRuntime);\n postLoad(gltfRuntime);\n if (!GLTFFileLoader.IncrementalLoading) {\n onSuccess();\n }\n });\n });\n if (GLTFFileLoader.IncrementalLoading) {\n onSuccess();\n }\n }, onError);\n }, onError);\n }\n /**\n * Imports all objects from a loaded gltf file and adds them to the scene\n * @param scene the scene the objects should be added to\n * @param data gltf data containing information of the meshes in a loaded file\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @returns a promise which completes when objects have been loaded to the scene\n */\n loadAsync(scene, data, rootUrl, onProgress) {\n return new Promise((resolve, reject) => {\n this._loadAsync(scene, data, rootUrl, () => {\n resolve();\n }, onProgress, message => {\n reject(new Error(message));\n });\n });\n }\n _loadShadersAsync(gltfRuntime, onload) {\n let hasShaders = false;\n const processShader = (sha, shader) => {\n GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, shaderString => {\n if (shaderString instanceof ArrayBuffer) {\n return;\n }\n gltfRuntime.loadedShaderCount++;\n if (shaderString) {\n Effect.ShadersStore[sha + (shader.type === EShaderType.VERTEX ? \"VertexShader\" : \"PixelShader\")] = shaderString;\n }\n if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) {\n onload();\n }\n }, () => {\n Tools.Error(\"Error when loading shader program named \" + sha + \" located at \" + shader.uri);\n });\n };\n for (const sha in gltfRuntime.shaders) {\n hasShaders = true;\n const shader = gltfRuntime.shaders[sha];\n if (shader) {\n processShader.bind(this, sha, shader)();\n } else {\n Tools.Error(\"No shader named: \" + sha);\n }\n }\n if (!hasShaders) {\n onload();\n }\n }\n _loadBuffersAsync(gltfRuntime, onLoad) {\n let hasBuffers = false;\n const processBuffer = (buf, buffer) => {\n GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, bufferView => {\n gltfRuntime.loadedBufferCount++;\n if (bufferView) {\n if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) {\n Tools.Error(\"Buffer named \" + buf + \" is length \" + bufferView.byteLength + \". Expected: \" + buffer.byteLength); // Improve error message\n }\n gltfRuntime.loadedBufferViews[buf] = bufferView;\n }\n if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) {\n onLoad();\n }\n }, () => {\n Tools.Error(\"Error when loading buffer named \" + buf + \" located at \" + buffer.uri);\n });\n };\n for (const buf in gltfRuntime.buffers) {\n hasBuffers = true;\n const buffer = gltfRuntime.buffers[buf];\n if (buffer) {\n processBuffer.bind(this, buf, buffer)();\n } else {\n Tools.Error(\"No buffer named: \" + buf);\n }\n }\n if (!hasBuffers) {\n onLoad();\n }\n }\n _createNodes(gltfRuntime) {\n let currentScene = gltfRuntime.currentScene;\n if (currentScene) {\n // Only one scene even if multiple scenes are defined\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n } else {\n // Load all scenes\n for (const thing in gltfRuntime.scenes) {\n currentScene = gltfRuntime.scenes[thing];\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n }\n }\n}\nGLTFLoader.Extensions = {};\n/** @internal */\nexport class GLTFLoaderExtension {\n constructor(name) {\n this._name = name;\n }\n get name() {\n return this._name;\n }\n /**\n * Defines an override for loading the runtime\n * Return true to stop further extensions from loading the runtime\n * @param scene\n * @param data\n * @param rootUrl\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading the runtime\n */\n loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an onverride for creating gltf runtime\n * Return true to stop further extensions from creating the runtime\n * @param gltfRuntime\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from creating the runtime\n */\n loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading buffers\n * Return true to stop further extensions from loading this buffer\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @param onProgress\n * @returns true to stop further extensions from loading this buffer\n */\n loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n return false;\n }\n /**\n * Defines an override for loading texture buffers\n * Return true to stop further extensions from loading this texture data\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this texture data\n */\n loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for creating textures\n * Return true to stop further extensions from loading this texture\n * @param gltfRuntime\n * @param id\n * @param buffer\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this texture\n */\n createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading shader strings\n * Return true to stop further extensions from loading this shader data\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this shader data\n */\n loadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading materials\n * Return true to stop further extensions from loading this material\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this material\n */\n loadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n // ---------\n // Utilities\n // ---------\n static LoadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);\n }, () => {\n setTimeout(() => {\n if (!onSuccess) {\n return;\n }\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\n });\n });\n }\n static LoadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);\n }, () => {\n setTimeout(() => {\n onSuccess();\n });\n });\n }\n static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);\n }, () => {\n GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);\n });\n }\n static LoadTextureAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, buffer => {\n if (buffer) {\n GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);\n }\n }, onError);\n }\n static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static _LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static _CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions(loaderExtension => {\n return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess);\n });\n }\n static _ApplyExtensions(func, defaultFunc) {\n for (const extensionName in GLTFLoader.Extensions) {\n const loaderExtension = GLTFLoader.Extensions[extensionName];\n if (func(loaderExtension)) {\n return;\n }\n }\n defaultFunc();\n }\n}\nGLTFFileLoader._CreateGLTF1Loader = () => new GLTFLoader();","map":{"version":3,"names":["EParameterType","ETextureFilterType","ECullingType","EBlendingFunction","EShaderType","Quaternion","Vector3","Matrix","Color3","Tools","Camera","FreeCamera","Animation","Bone","Skeleton","Effect","Material","MultiMaterial","StandardMaterial","ShaderMaterial","Texture","VertexData","VertexBuffer","Geometry","SubMesh","AbstractMesh","Mesh","HemisphericLight","DirectionalLight","PointLight","SpotLight","GLTFUtils","GLTFFileLoader","Constants","ETokenType","Tokenizer","constructor","toParse","_pos","currentToken","UNKNOWN","currentIdentifier","currentString","isLetterOrDigitPattern","_toParse","_maxPos","length","getNextToken","isEnd","END_OF_INPUT","read","test","IDENTIFIER","peek","forward","glTFTransforms","babylonTransforms","glTFAnimationPaths","babylonAnimationPaths","parseBuffers","parsedBuffers","gltfRuntime","buf","parsedBuffer","buffers","buffersCount","parseShaders","parsedShaders","sha","parsedShader","shaders","shaderscount","parseObject","parsedObjects","runtimeProperty","object","parsedObject","normalizeUVs","buffer","i","getAttribute","attributeParameter","semantic","indexOf","channel","Number","split","loadAnimations","anim","animations","animation","channels","samplers","lastAnimation","sampler","inputData","outputData","parameters","input","output","bufferInput","GetBufferFromAccessor","accessors","bufferOutput","targetId","target","id","targetNode","scene","getNodeById","getNodeByName","Warn","isBone","targetPath","path","targetPathIndex","animationType","ANIMATIONTYPE_MATRIX","ANIMATIONTYPE_QUATERNION","rotationQuaternion","ANIMATIONTYPE_VECTOR3","babylonAnimation","keys","arrayOffset","modifyKey","getKeys","_blockEntityCollection","assetContainer","ANIMATIONLOOPMODE_CYCLE","j","value","FromArray","bone","translation","Zero","scaling","mat","getBaseMatrix","decompose","Compose","push","frame","setKeys","stopAnimation","beginAnimation","configureBoneTransformation","node","rotation","scale","position","matrix","getParentBone","skins","jointName","newSkeleton","bones","name","nodes","nde","children","child","getNodeToRoot","nodesToRoot","nodeToRoot","getJointNode","nodeIsInJoints","jointNames","getNodesToRoot","k","_parent","importSkeleton","mesh","babylonSkeleton","nodesToRootToAdd","jointNode","existingBone","getBoneById","foundBone","parentBone","joint","prepare","importMesh","meshes","newMesh","_parentContainer","babylonNode","subMaterials","vertexData","verticesStarts","verticesCounts","indexStarts","indexCounts","meshIndex","meshId","primitives","tempVertexData","primitive","mode","attributes","accessor","normals","Float32Array","set","HomogeneousCoordinates","positions","uvKind","UVKind","uvs","matricesIndices","matricesWeights","colors","indices","Int32Array","merge","material","getMaterialById","GetDefaultMaterial","computeWorldMatrix","subMeshes","index","AddToMesh","configureNode","newNode","configureNodeFromMatrix","importNode","lastNode","importOnlyMeshes","skin","importMeshesNames","skeleton","getLastSkeletonById","light","lights","type","ambienLight","hemiLight","color","diffuse","directionalLight","dirLight","pointLight","ptLight","spotLight","spLight","fallOfAngle","angle","fallOffExponent","exponent","camera","cameras","orthoCamera","ORTHOGRAPHIC_CAMERA","attachControl","perspectiveCamera","persCamera","aspectRatio","getEngine","getRenderWidth","getRenderHeight","znear","zfar","maxZ","minZ","dummy","updateCache","traverseNodes","parent","meshIncluded","postLoad","currentScene","thing","scenes","skeletons","MAX_VALUE","onBindShaderMaterial","unTreatedUniforms","shaderMaterial","technique","onSuccess","materialValues","values","unif","uniform","FLOAT_MAT2","FLOAT_MAT3","FLOAT_MAT4","source","SetMatrix","getEffect","uniforms","SAMPLER_2D","texture","textures","babylonTexture","undefined","setTexture","SetUniform","prepareShaderMaterialUniforms","techniqueUniforms","onLoadTexture","uniformName","GLTFLoaderExtension","LoadTextureAsync","onShaderCompileError","program","onError","effect","error","dispose","onShaderCompileSuccess","_","onBind","parseShaderUniforms","tokenizer","uniformParameter","transformIndex","importMaterials","materials","LoadMaterialAsync","GLTFLoaderBase","CreateRuntime","parsedData","rootUrl","extensions","bufferViews","images","programs","techniques","extensionsUsed","loadedBufferCount","loadedBufferViews","loadedShaderCount","dummyNodes","LoadBufferAsync","onProgress","IsBase64","uri","setTimeout","Uint8Array","DecodeBase64","LoadFile","data","request","status","statusText","LoadTextureBufferAsync","CreateTextureAsync","createMipMaps","minFilter","NEAREST_MIPMAP_NEAREST","NEAREST_MIPMAP_LINEAR","LINEAR_MIPMAP_NEAREST","LINEAR_MIPMAP_LINEAR","samplingMode","BILINEAR_SAMPLINGMODE","blob","Blob","blobURL","URL","createObjectURL","revokeBlobURL","revokeObjectURL","newTexture","wrapS","wrapU","GetWrapMode","wrapT","wrapV","LoadShaderStringAsync","shader","shaderString","atob","defaultMaterial","diffuseColor","sideOrientation","CounterClockWiseSideOrientation","states","vertexShader","ShadersStore","pixelShader","fragmentShader","newVertexShader","newPixelShader","vertexTokenizer","pixelTokenizer","attr","attribute","tokenType","foundAttribute","shaderPath","vertex","fragment","options","needAlphaBlending","enable","onCompiled","functions","cullFace","BACK","backFaceCulling","blendFunc","blendFuncSeparate","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","ONE","alphaMode","ALPHA_COMBINE","ZERO","ALPHA_ONEONE","ALPHA_ADD","ONE_MINUS_SRC_COLOR","ALPHA_SUBTRACT","DST_COLOR","ALPHA_MULTIPLY","ALPHA_MAXIMIZED","GLTFLoader","RegisterExtension","extension","Extensions","Error","_importMeshAsync","meshesNames","useRightHandedSystem","LoadRuntimeAsync","Array","_createNodes","skl","_loadBuffersAsync","_loadShadersAsync","IncrementalLoading","importMeshAsync","Promise","resolve","reject","particleSystems","animationGroups","transformNodes","geometries","spriteManagers","message","_loadAsync","LoadRuntimeExtensionsAsync","loadAsync","onload","hasShaders","processShader","ArrayBuffer","VERTEX","bind","onLoad","hasBuffers","processBuffer","bufferView","byteLength","_name","loadRuntimeAsync","loadRuntimeExtensionsAsync","loadBufferAsync","loadTextureBufferAsync","createTextureAsync","loadShaderStringAsync","loadMaterialAsync","_ApplyExtensions","loaderExtension","json","_LoadTextureBufferAsync","_CreateTextureAsync","func","defaultFunc","extensionName","_CreateGLTF1Loader"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/1.0/glTFLoader.js"],"sourcesContent":["import { EParameterType, ETextureFilterType, ECullingType, EBlendingFunction, EShaderType } from \"./glTFLoaderInterfaces.js\";\nimport { Quaternion, Vector3, Matrix } from \"@babylonjs/core/Maths/math.vector.js\";\nimport { Color3 } from \"@babylonjs/core/Maths/math.color.js\";\nimport { Tools } from \"@babylonjs/core/Misc/tools.js\";\nimport { Camera } from \"@babylonjs/core/Cameras/camera.js\";\nimport { FreeCamera } from \"@babylonjs/core/Cameras/freeCamera.js\";\nimport { Animation } from \"@babylonjs/core/Animations/animation.js\";\nimport { Bone } from \"@babylonjs/core/Bones/bone.js\";\nimport { Skeleton } from \"@babylonjs/core/Bones/skeleton.js\";\nimport { Effect } from \"@babylonjs/core/Materials/effect.js\";\nimport { Material } from \"@babylonjs/core/Materials/material.js\";\nimport { MultiMaterial } from \"@babylonjs/core/Materials/multiMaterial.js\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial.js\";\nimport { ShaderMaterial } from \"@babylonjs/core/Materials/shaderMaterial.js\";\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture.js\";\nimport { VertexData } from \"@babylonjs/core/Meshes/mesh.vertexData.js\";\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer.js\";\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry.js\";\nimport { SubMesh } from \"@babylonjs/core/Meshes/subMesh.js\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh.js\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh.js\";\nimport { HemisphericLight } from \"@babylonjs/core/Lights/hemisphericLight.js\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight.js\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight.js\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight.js\";\nimport { GLTFUtils } from \"./glTFLoaderUtils.js\";\nimport { GLTFFileLoader } from \"../glTFFileLoader.js\";\nimport { Constants } from \"@babylonjs/core/Engines/constants.js\";\n/**\n * Tokenizer. Used for shaders compatibility\n * Automatically map world, view, projection, worldViewProjection, attributes and so on\n */\nvar ETokenType;\n(function (ETokenType) {\n ETokenType[ETokenType[\"IDENTIFIER\"] = 1] = \"IDENTIFIER\";\n ETokenType[ETokenType[\"UNKNOWN\"] = 2] = \"UNKNOWN\";\n ETokenType[ETokenType[\"END_OF_INPUT\"] = 3] = \"END_OF_INPUT\";\n})(ETokenType || (ETokenType = {}));\nclass Tokenizer {\n constructor(toParse) {\n this._pos = 0;\n this.currentToken = ETokenType.UNKNOWN;\n this.currentIdentifier = \"\";\n this.currentString = \"\";\n this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/;\n this._toParse = toParse;\n this._maxPos = toParse.length;\n }\n getNextToken() {\n if (this.isEnd()) {\n return ETokenType.END_OF_INPUT;\n }\n this.currentString = this.read();\n this.currentToken = ETokenType.UNKNOWN;\n if (this.currentString === \"_\" || this.isLetterOrDigitPattern.test(this.currentString)) {\n this.currentToken = ETokenType.IDENTIFIER;\n this.currentIdentifier = this.currentString;\n while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === \"_\")) {\n this.currentIdentifier += this.currentString;\n this.forward();\n }\n }\n return this.currentToken;\n }\n peek() {\n return this._toParse[this._pos];\n }\n read() {\n return this._toParse[this._pos++];\n }\n forward() {\n this._pos++;\n }\n isEnd() {\n return this._pos >= this._maxPos;\n }\n}\n/**\n * Values\n */\nconst glTFTransforms = [\"MODEL\", \"VIEW\", \"PROJECTION\", \"MODELVIEW\", \"MODELVIEWPROJECTION\", \"JOINTMATRIX\"];\nconst babylonTransforms = [\"world\", \"view\", \"projection\", \"worldView\", \"worldViewProjection\", \"mBones\"];\nconst glTFAnimationPaths = [\"translation\", \"rotation\", \"scale\"];\nconst babylonAnimationPaths = [\"position\", \"rotationQuaternion\", \"scaling\"];\n/**\n * Parse\n * @param parsedBuffers\n * @param gltfRuntime\n */\nconst parseBuffers = (parsedBuffers, gltfRuntime) => {\n for (const buf in parsedBuffers) {\n const parsedBuffer = parsedBuffers[buf];\n gltfRuntime.buffers[buf] = parsedBuffer;\n gltfRuntime.buffersCount++;\n }\n};\nconst parseShaders = (parsedShaders, gltfRuntime) => {\n for (const sha in parsedShaders) {\n const parsedShader = parsedShaders[sha];\n gltfRuntime.shaders[sha] = parsedShader;\n gltfRuntime.shaderscount++;\n }\n};\nconst parseObject = (parsedObjects, runtimeProperty, gltfRuntime) => {\n for (const object in parsedObjects) {\n const parsedObject = parsedObjects[object];\n gltfRuntime[runtimeProperty][object] = parsedObject;\n }\n};\n/**\n * Utils\n * @param buffer\n */\nconst normalizeUVs = (buffer) => {\n if (!buffer) {\n return;\n }\n for (let i = 0; i < buffer.length / 2; i++) {\n buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];\n }\n};\nconst getAttribute = (attributeParameter) => {\n if (attributeParameter.semantic === \"NORMAL\") {\n return \"normal\";\n }\n else if (attributeParameter.semantic === \"POSITION\") {\n return \"position\";\n }\n else if (attributeParameter.semantic === \"JOINT\") {\n return \"matricesIndices\";\n }\n else if (attributeParameter.semantic === \"WEIGHT\") {\n return \"matricesWeights\";\n }\n else if (attributeParameter.semantic === \"COLOR\") {\n return \"color\";\n }\n else if (attributeParameter.semantic && attributeParameter.semantic.indexOf(\"TEXCOORD_\") !== -1) {\n const channel = Number(attributeParameter.semantic.split(\"_\")[1]);\n return \"uv\" + (channel === 0 ? \"\" : channel + 1);\n }\n return null;\n};\n/**\n * Loads and creates animations\n * @param gltfRuntime\n */\nconst loadAnimations = (gltfRuntime) => {\n for (const anim in gltfRuntime.animations) {\n const animation = gltfRuntime.animations[anim];\n if (!animation.channels || !animation.samplers) {\n continue;\n }\n let lastAnimation = null;\n for (let i = 0; i < animation.channels.length; i++) {\n // Get parameters and load buffers\n const channel = animation.channels[i];\n const sampler = animation.samplers[channel.sampler];\n if (!sampler) {\n continue;\n }\n let inputData = null;\n let outputData = null;\n if (animation.parameters) {\n inputData = animation.parameters[sampler.input];\n outputData = animation.parameters[sampler.output];\n }\n else {\n inputData = sampler.input;\n outputData = sampler.output;\n }\n const bufferInput = GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]);\n const bufferOutput = GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]);\n const targetId = channel.target.id;\n let targetNode = gltfRuntime.scene.getNodeById(targetId);\n if (targetNode === null) {\n targetNode = gltfRuntime.scene.getNodeByName(targetId);\n }\n if (targetNode === null) {\n Tools.Warn(\"Creating animation named \" + anim + \". But cannot find node named \" + targetId + \" to attach to\");\n continue;\n }\n const isBone = targetNode instanceof Bone;\n // Get target path (position, rotation or scaling)\n let targetPath = channel.target.path;\n const targetPathIndex = glTFAnimationPaths.indexOf(targetPath);\n if (targetPathIndex !== -1) {\n targetPath = babylonAnimationPaths[targetPathIndex];\n }\n // Determine animation type\n let animationType = Animation.ANIMATIONTYPE_MATRIX;\n if (!isBone) {\n if (targetPath === \"rotationQuaternion\") {\n animationType = Animation.ANIMATIONTYPE_QUATERNION;\n targetNode.rotationQuaternion = new Quaternion();\n }\n else {\n animationType = Animation.ANIMATIONTYPE_VECTOR3;\n }\n }\n // Create animation and key frames\n let babylonAnimation = null;\n const keys = [];\n let arrayOffset = 0;\n let modifyKey = false;\n if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) {\n babylonAnimation = lastAnimation;\n modifyKey = true;\n }\n if (!modifyKey) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n babylonAnimation = new Animation(anim, isBone ? \"_matrix\" : targetPath, 1, animationType, Animation.ANIMATIONLOOPMODE_CYCLE);\n gltfRuntime.scene._blockEntityCollection = false;\n }\n // For each frame\n for (let j = 0; j < bufferInput.length; j++) {\n let value = null;\n if (targetPath === \"rotationQuaternion\") {\n // VEC4\n value = Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);\n arrayOffset += 4;\n }\n else {\n // Position and scaling are VEC3\n value = Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);\n arrayOffset += 3;\n }\n if (isBone) {\n const bone = targetNode;\n let translation = Vector3.Zero();\n let rotationQuaternion = new Quaternion();\n let scaling = Vector3.Zero();\n // Warning on decompose\n let mat = bone.getBaseMatrix();\n if (modifyKey && lastAnimation) {\n mat = lastAnimation.getKeys()[j].value;\n }\n mat.decompose(scaling, rotationQuaternion, translation);\n if (targetPath === \"position\") {\n translation = value;\n }\n else if (targetPath === \"rotationQuaternion\") {\n rotationQuaternion = value;\n }\n else {\n scaling = value;\n }\n value = Matrix.Compose(scaling, rotationQuaternion, translation);\n }\n if (!modifyKey) {\n keys.push({\n frame: bufferInput[j],\n value: value,\n });\n }\n else if (lastAnimation) {\n lastAnimation.getKeys()[j].value = value;\n }\n }\n // Finish\n if (!modifyKey && babylonAnimation) {\n babylonAnimation.setKeys(keys);\n targetNode.animations.push(babylonAnimation);\n }\n lastAnimation = babylonAnimation;\n gltfRuntime.scene.stopAnimation(targetNode);\n gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);\n }\n }\n};\n/**\n * @returns the bones transformation matrix\n * @param node\n */\nconst configureBoneTransformation = (node) => {\n let mat = null;\n if (node.translation || node.rotation || node.scale) {\n const scale = Vector3.FromArray(node.scale || [1, 1, 1]);\n const rotation = Quaternion.FromArray(node.rotation || [0, 0, 0, 1]);\n const position = Vector3.FromArray(node.translation || [0, 0, 0]);\n mat = Matrix.Compose(scale, rotation, position);\n }\n else {\n mat = Matrix.FromArray(node.matrix);\n }\n return mat;\n};\n/**\n * Returns the parent bone\n * @param gltfRuntime\n * @param skins\n * @param jointName\n * @param newSkeleton\n * @returns the parent bone\n */\nconst getParentBone = (gltfRuntime, skins, jointName, newSkeleton) => {\n // Try to find\n for (let i = 0; i < newSkeleton.bones.length; i++) {\n if (newSkeleton.bones[i].name === jointName) {\n return newSkeleton.bones[i];\n }\n }\n // Not found, search in gltf nodes\n const nodes = gltfRuntime.nodes;\n for (const nde in nodes) {\n const node = nodes[nde];\n if (!node.jointName) {\n continue;\n }\n const children = node.children;\n for (let i = 0; i < children.length; i++) {\n const child = gltfRuntime.nodes[children[i]];\n if (!child.jointName) {\n continue;\n }\n if (child.jointName === jointName) {\n const mat = configureBoneTransformation(node);\n const bone = new Bone(node.name || \"\", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);\n bone.id = nde;\n return bone;\n }\n }\n }\n return null;\n};\n/**\n * Returns the appropriate root node\n * @param nodesToRoot\n * @param id\n * @returns the root node\n */\nconst getNodeToRoot = (nodesToRoot, id) => {\n for (let i = 0; i < nodesToRoot.length; i++) {\n const nodeToRoot = nodesToRoot[i];\n for (let j = 0; j < nodeToRoot.node.children.length; j++) {\n const child = nodeToRoot.node.children[j];\n if (child === id) {\n return nodeToRoot.bone;\n }\n }\n }\n return null;\n};\n/**\n * Returns the node with the joint name\n * @param gltfRuntime\n * @param jointName\n * @returns the node with the joint name\n */\nconst getJointNode = (gltfRuntime, jointName) => {\n const nodes = gltfRuntime.nodes;\n let node = nodes[jointName];\n if (node) {\n return {\n node: node,\n id: jointName,\n };\n }\n for (const nde in nodes) {\n node = nodes[nde];\n if (node.jointName === jointName) {\n return {\n node: node,\n id: nde,\n };\n }\n }\n return null;\n};\n/**\n * Checks if a nodes is in joints\n * @param skins\n * @param id\n * @returns true if the node is in joints, else false\n */\nconst nodeIsInJoints = (skins, id) => {\n for (let i = 0; i < skins.jointNames.length; i++) {\n if (skins.jointNames[i] === id) {\n return true;\n }\n }\n return false;\n};\n/**\n * Fills the nodes to root for bones and builds hierarchy\n * @param gltfRuntime\n * @param newSkeleton\n * @param skins\n * @param nodesToRoot\n */\nconst getNodesToRoot = (gltfRuntime, newSkeleton, skins, nodesToRoot) => {\n // Creates nodes for root\n for (const nde in gltfRuntime.nodes) {\n const node = gltfRuntime.nodes[nde];\n const id = nde;\n if (!node.jointName || nodeIsInJoints(skins, node.jointName)) {\n continue;\n }\n // Create node to root bone\n const mat = configureBoneTransformation(node);\n const bone = new Bone(node.name || \"\", newSkeleton, null, mat);\n bone.id = id;\n nodesToRoot.push({ bone: bone, node: node, id: id });\n }\n // Parenting\n for (let i = 0; i < nodesToRoot.length; i++) {\n const nodeToRoot = nodesToRoot[i];\n const children = nodeToRoot.node.children;\n for (let j = 0; j < children.length; j++) {\n let child = null;\n for (let k = 0; k < nodesToRoot.length; k++) {\n if (nodesToRoot[k].id === children[j]) {\n child = nodesToRoot[k];\n break;\n }\n }\n if (child) {\n child.bone._parent = nodeToRoot.bone;\n nodeToRoot.bone.children.push(child.bone);\n }\n }\n }\n};\n/**\n * Imports a skeleton\n * @param gltfRuntime\n * @param skins\n * @param mesh\n * @param newSkeleton\n * @returns the bone name\n */\nconst importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {\n if (!newSkeleton) {\n newSkeleton = new Skeleton(skins.name || \"\", \"\", gltfRuntime.scene);\n }\n if (!skins.babylonSkeleton) {\n return newSkeleton;\n }\n // Find the root bones\n const nodesToRoot = [];\n const nodesToRootToAdd = [];\n getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);\n newSkeleton.bones = [];\n // Joints\n for (let i = 0; i < skins.jointNames.length; i++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);\n if (!jointNode) {\n continue;\n }\n const node = jointNode.node;\n if (!node) {\n Tools.Warn(\"Joint named \" + skins.jointNames[i] + \" does not exist\");\n continue;\n }\n const id = jointNode.id;\n // Optimize, if the bone already exists...\n const existingBone = gltfRuntime.scene.getBoneById(id);\n if (existingBone) {\n newSkeleton.bones.push(existingBone);\n continue;\n }\n // Search for parent bone\n let foundBone = false;\n let parentBone = null;\n for (let j = 0; j < i; j++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[j]);\n if (!jointNode) {\n continue;\n }\n const joint = jointNode.node;\n if (!joint) {\n Tools.Warn(\"Joint named \" + skins.jointNames[j] + \" does not exist when looking for parent\");\n continue;\n }\n const children = joint.children;\n if (!children) {\n continue;\n }\n foundBone = false;\n for (let k = 0; k < children.length; k++) {\n if (children[k] === id) {\n parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);\n foundBone = true;\n break;\n }\n }\n if (foundBone) {\n break;\n }\n }\n // Create bone\n const mat = configureBoneTransformation(node);\n if (!parentBone && nodesToRoot.length > 0) {\n parentBone = getNodeToRoot(nodesToRoot, id);\n if (parentBone) {\n if (nodesToRootToAdd.indexOf(parentBone) === -1) {\n nodesToRootToAdd.push(parentBone);\n }\n }\n }\n const bone = new Bone(node.jointName || \"\", newSkeleton, parentBone, mat);\n bone.id = id;\n }\n // Polish\n const bones = newSkeleton.bones;\n newSkeleton.bones = [];\n for (let i = 0; i < skins.jointNames.length; i++) {\n const jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);\n if (!jointNode) {\n continue;\n }\n for (let j = 0; j < bones.length; j++) {\n if (bones[j].id === jointNode.id) {\n newSkeleton.bones.push(bones[j]);\n break;\n }\n }\n }\n newSkeleton.prepare();\n // Finish\n for (let i = 0; i < nodesToRootToAdd.length; i++) {\n newSkeleton.bones.push(nodesToRootToAdd[i]);\n }\n return newSkeleton;\n};\n/**\n * Imports a mesh and its geometries\n * @param gltfRuntime\n * @param node\n * @param meshes\n * @param id\n * @param newMesh\n * @returns the new mesh\n */\nconst importMesh = (gltfRuntime, node, meshes, id, newMesh) => {\n if (!newMesh) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n newMesh = new Mesh(node.name || \"\", gltfRuntime.scene);\n newMesh._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n newMesh.id = id;\n }\n if (!node.babylonNode) {\n return newMesh;\n }\n const subMaterials = [];\n let vertexData = null;\n const verticesStarts = [];\n const verticesCounts = [];\n const indexStarts = [];\n const indexCounts = [];\n for (let meshIndex = 0; meshIndex < meshes.length; meshIndex++) {\n const meshId = meshes[meshIndex];\n const mesh = gltfRuntime.meshes[meshId];\n if (!mesh) {\n continue;\n }\n // Positions, normals and UVs\n for (let i = 0; i < mesh.primitives.length; i++) {\n // Temporary vertex data\n const tempVertexData = new VertexData();\n const primitive = mesh.primitives[i];\n if (primitive.mode !== 4) {\n // continue;\n }\n const attributes = primitive.attributes;\n let accessor = null;\n let buffer = null;\n // Set positions, normal and uvs\n for (const semantic in attributes) {\n // Link accessor and buffer view\n accessor = gltfRuntime.accessors[attributes[semantic]];\n buffer = GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);\n if (semantic === \"NORMAL\") {\n tempVertexData.normals = new Float32Array(buffer.length);\n tempVertexData.normals.set(buffer);\n }\n else if (semantic === \"POSITION\") {\n if (GLTFFileLoader.HomogeneousCoordinates) {\n tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);\n for (let j = 0; j < buffer.length; j += 4) {\n tempVertexData.positions[j] = buffer[j];\n tempVertexData.positions[j + 1] = buffer[j + 1];\n tempVertexData.positions[j + 2] = buffer[j + 2];\n }\n }\n else {\n tempVertexData.positions = new Float32Array(buffer.length);\n tempVertexData.positions.set(buffer);\n }\n verticesCounts.push(tempVertexData.positions.length);\n }\n else if (semantic.indexOf(\"TEXCOORD_\") !== -1) {\n const channel = Number(semantic.split(\"_\")[1]);\n const uvKind = VertexBuffer.UVKind + (channel === 0 ? \"\" : channel + 1);\n const uvs = new Float32Array(buffer.length);\n uvs.set(buffer);\n normalizeUVs(uvs);\n tempVertexData.set(uvs, uvKind);\n }\n else if (semantic === \"JOINT\") {\n tempVertexData.matricesIndices = new Float32Array(buffer.length);\n tempVertexData.matricesIndices.set(buffer);\n }\n else if (semantic === \"WEIGHT\") {\n tempVertexData.matricesWeights = new Float32Array(buffer.length);\n tempVertexData.matricesWeights.set(buffer);\n }\n else if (semantic === \"COLOR\") {\n tempVertexData.colors = new Float32Array(buffer.length);\n tempVertexData.colors.set(buffer);\n }\n }\n // Indices\n accessor = gltfRuntime.accessors[primitive.indices];\n if (accessor) {\n buffer = GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);\n tempVertexData.indices = new Int32Array(buffer.length);\n tempVertexData.indices.set(buffer);\n indexCounts.push(tempVertexData.indices.length);\n }\n else {\n // Set indices on the fly\n const indices = [];\n for (let j = 0; j < tempVertexData.positions.length / 3; j++) {\n indices.push(j);\n }\n tempVertexData.indices = new Int32Array(indices);\n indexCounts.push(tempVertexData.indices.length);\n }\n if (!vertexData) {\n vertexData = tempVertexData;\n }\n else {\n vertexData.merge(tempVertexData);\n }\n // Sub material\n const material = gltfRuntime.scene.getMaterialById(primitive.material);\n subMaterials.push(material === null ? GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material);\n // Update vertices start and index start\n verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);\n indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);\n }\n }\n let material;\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n if (subMaterials.length > 1) {\n material = new MultiMaterial(\"multimat\" + id, gltfRuntime.scene);\n material.subMaterials = subMaterials;\n }\n else {\n material = new StandardMaterial(\"multimat\" + id, gltfRuntime.scene);\n }\n if (subMaterials.length === 1) {\n material = subMaterials[0];\n }\n material._parentContainer = gltfRuntime.assetContainer;\n if (!newMesh.material) {\n newMesh.material = material;\n }\n // Apply geometry\n new Geometry(id, gltfRuntime.scene, vertexData, false, newMesh);\n newMesh.computeWorldMatrix(true);\n gltfRuntime.scene._blockEntityCollection = false;\n // Apply submeshes\n newMesh.subMeshes = [];\n let index = 0;\n for (let meshIndex = 0; meshIndex < meshes.length; meshIndex++) {\n const meshId = meshes[meshIndex];\n const mesh = gltfRuntime.meshes[meshId];\n if (!mesh) {\n continue;\n }\n for (let i = 0; i < mesh.primitives.length; i++) {\n if (mesh.primitives[i].mode !== 4) {\n //continue;\n }\n SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true);\n index++;\n }\n }\n // Finish\n return newMesh;\n};\n/**\n * Configure node transformation from position, rotation and scaling\n * @param newNode\n * @param position\n * @param rotation\n * @param scaling\n */\nconst configureNode = (newNode, position, rotation, scaling) => {\n if (newNode.position) {\n newNode.position = position;\n }\n if (newNode.rotationQuaternion || newNode.rotation) {\n newNode.rotationQuaternion = rotation;\n }\n if (newNode.scaling) {\n newNode.scaling = scaling;\n }\n};\n/**\n * Configures node from transformation matrix\n * @param newNode\n * @param node\n */\nconst configureNodeFromMatrix = (newNode, node) => {\n if (node.matrix) {\n const position = new Vector3(0, 0, 0);\n const rotation = new Quaternion();\n const scaling = new Vector3(0, 0, 0);\n const mat = Matrix.FromArray(node.matrix);\n mat.decompose(scaling, rotation, position);\n configureNode(newNode, position, rotation, scaling);\n }\n else if (node.translation && node.rotation && node.scale) {\n configureNode(newNode, Vector3.FromArray(node.translation), Quaternion.FromArray(node.rotation), Vector3.FromArray(node.scale));\n }\n newNode.computeWorldMatrix(true);\n};\n/**\n * Imports a node\n * @param gltfRuntime\n * @param node\n * @param id\n * @returns the newly imported node\n */\nconst importNode = (gltfRuntime, node, id) => {\n let lastNode = null;\n if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {\n if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || \"\") === -1) {\n return null;\n }\n }\n // Meshes\n if (node.skin) {\n if (node.meshes) {\n const skin = gltfRuntime.skins[node.skin];\n const newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);\n newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);\n if (newMesh.skeleton === null) {\n newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton);\n if (!skin.babylonSkeleton) {\n skin.babylonSkeleton = newMesh.skeleton;\n }\n }\n lastNode = newMesh;\n }\n }\n else if (node.meshes) {\n /**\n * Improve meshes property\n */\n const newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);\n lastNode = newMesh;\n }\n // Lights\n else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {\n const light = gltfRuntime.lights[node.light];\n if (light) {\n if (light.type === \"ambient\") {\n const ambienLight = light[light.type];\n const hemiLight = new HemisphericLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n hemiLight.name = node.name || \"\";\n if (ambienLight.color) {\n hemiLight.diffuse = Color3.FromArray(ambienLight.color);\n }\n lastNode = hemiLight;\n }\n else if (light.type === \"directional\") {\n const directionalLight = light[light.type];\n const dirLight = new DirectionalLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n dirLight.name = node.name || \"\";\n if (directionalLight.color) {\n dirLight.diffuse = Color3.FromArray(directionalLight.color);\n }\n lastNode = dirLight;\n }\n else if (light.type === \"point\") {\n const pointLight = light[light.type];\n const ptLight = new PointLight(node.light, Vector3.Zero(), gltfRuntime.scene);\n ptLight.name = node.name || \"\";\n if (pointLight.color) {\n ptLight.diffuse = Color3.FromArray(pointLight.color);\n }\n lastNode = ptLight;\n }\n else if (light.type === \"spot\") {\n const spotLight = light[light.type];\n const spLight = new SpotLight(node.light, Vector3.Zero(), Vector3.Zero(), 0, 0, gltfRuntime.scene);\n spLight.name = node.name || \"\";\n if (spotLight.color) {\n spLight.diffuse = Color3.FromArray(spotLight.color);\n }\n if (spotLight.fallOfAngle) {\n spLight.angle = spotLight.fallOfAngle;\n }\n if (spotLight.fallOffExponent) {\n spLight.exponent = spotLight.fallOffExponent;\n }\n lastNode = spLight;\n }\n }\n }\n // Cameras\n else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {\n const camera = gltfRuntime.cameras[node.camera];\n if (camera) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n if (camera.type === \"orthographic\") {\n const orthoCamera = new FreeCamera(node.camera, Vector3.Zero(), gltfRuntime.scene, false);\n orthoCamera.name = node.name || \"\";\n orthoCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;\n orthoCamera.attachControl();\n lastNode = orthoCamera;\n orthoCamera._parentContainer = gltfRuntime.assetContainer;\n }\n else if (camera.type === \"perspective\") {\n const perspectiveCamera = camera[camera.type];\n const persCamera = new FreeCamera(node.camera, Vector3.Zero(), gltfRuntime.scene, false);\n persCamera.name = node.name || \"\";\n persCamera.attachControl();\n if (!perspectiveCamera.aspectRatio) {\n perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight();\n }\n if (perspectiveCamera.znear && perspectiveCamera.zfar) {\n persCamera.maxZ = perspectiveCamera.zfar;\n persCamera.minZ = perspectiveCamera.znear;\n }\n lastNode = persCamera;\n persCamera._parentContainer = gltfRuntime.assetContainer;\n }\n gltfRuntime.scene._blockEntityCollection = false;\n }\n }\n // Empty node\n if (!node.jointName) {\n if (node.babylonNode) {\n return node.babylonNode;\n }\n else if (lastNode === null) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n const dummy = new Mesh(node.name || \"\", gltfRuntime.scene);\n dummy._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n node.babylonNode = dummy;\n lastNode = dummy;\n }\n }\n if (lastNode !== null) {\n if (node.matrix && lastNode instanceof Mesh) {\n configureNodeFromMatrix(lastNode, node);\n }\n else {\n const translation = node.translation || [0, 0, 0];\n const rotation = node.rotation || [0, 0, 0, 1];\n const scale = node.scale || [1, 1, 1];\n configureNode(lastNode, Vector3.FromArray(translation), Quaternion.FromArray(rotation), Vector3.FromArray(scale));\n }\n lastNode.updateCache(true);\n node.babylonNode = lastNode;\n }\n return lastNode;\n};\n/**\n * Traverses nodes and creates them\n * @param gltfRuntime\n * @param id\n * @param parent\n * @param meshIncluded\n */\nconst traverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {\n const node = gltfRuntime.nodes[id];\n let newNode = null;\n if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {\n if (gltfRuntime.importMeshesNames.indexOf(node.name || \"\") !== -1 || gltfRuntime.importMeshesNames.length === 0) {\n meshIncluded = true;\n }\n else {\n meshIncluded = false;\n }\n }\n else {\n meshIncluded = true;\n }\n if (!node.jointName && meshIncluded) {\n newNode = importNode(gltfRuntime, node, id);\n if (newNode !== null) {\n newNode.id = id;\n newNode.parent = parent;\n }\n }\n if (node.children) {\n for (let i = 0; i < node.children.length; i++) {\n traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);\n }\n }\n};\n/**\n * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)\n * @param gltfRuntime\n */\nconst postLoad = (gltfRuntime) => {\n // Nodes\n let currentScene = gltfRuntime.currentScene;\n if (currentScene) {\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n else {\n for (const thing in gltfRuntime.scenes) {\n currentScene = gltfRuntime.scenes[thing];\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n }\n // Set animations\n loadAnimations(gltfRuntime);\n for (let i = 0; i < gltfRuntime.scene.skeletons.length; i++) {\n const skeleton = gltfRuntime.scene.skeletons[i];\n gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);\n }\n};\n/**\n * onBind shaderrs callback to set uniforms and matrices\n * @param mesh\n * @param gltfRuntime\n * @param unTreatedUniforms\n * @param shaderMaterial\n * @param technique\n * @param material\n * @param onSuccess\n */\nconst onBindShaderMaterial = (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) => {\n const materialValues = material.values || technique.parameters;\n for (const unif in unTreatedUniforms) {\n const uniform = unTreatedUniforms[unif];\n const type = uniform.type;\n if (type === EParameterType.FLOAT_MAT2 || type === EParameterType.FLOAT_MAT3 || type === EParameterType.FLOAT_MAT4) {\n if (uniform.semantic && !uniform.source && !uniform.node) {\n GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect());\n }\n else if (uniform.semantic && (uniform.source || uniform.node)) {\n let source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || \"\");\n if (source === null) {\n source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || \"\");\n }\n if (source === null) {\n continue;\n }\n GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect());\n }\n }\n else {\n const value = materialValues[technique.uniforms[unif]];\n if (!value) {\n continue;\n }\n if (type === EParameterType.SAMPLER_2D) {\n const texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture;\n if (texture === null || texture === undefined) {\n continue;\n }\n shaderMaterial.getEffect().setTexture(unif, texture);\n }\n else {\n GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type);\n }\n }\n }\n onSuccess(shaderMaterial);\n};\n/**\n * Prepare uniforms to send the only one time\n * Loads the appropriate textures\n * @param gltfRuntime\n * @param shaderMaterial\n * @param technique\n * @param material\n */\nconst prepareShaderMaterialUniforms = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) => {\n const materialValues = material.values || technique.parameters;\n const techniqueUniforms = technique.uniforms;\n /**\n * Prepare values here (not matrices)\n */\n for (const unif in unTreatedUniforms) {\n const uniform = unTreatedUniforms[unif];\n const type = uniform.type;\n let value = materialValues[techniqueUniforms[unif]];\n if (value === undefined) {\n // In case the value is the same for all materials\n value = uniform.value;\n }\n if (!value) {\n continue;\n }\n const onLoadTexture = (uniformName) => {\n return (texture) => {\n if (uniform.value && uniformName) {\n // Static uniform\n shaderMaterial.setTexture(uniformName, texture);\n delete unTreatedUniforms[uniformName];\n }\n };\n };\n // Texture (sampler2D)\n if (type === EParameterType.SAMPLER_2D) {\n GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), () => onLoadTexture(null));\n }\n // Others\n else {\n if (uniform.value && GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) {\n // Static uniform\n delete unTreatedUniforms[unif];\n }\n }\n }\n};\n/**\n * Shader compilation failed\n * @param program\n * @param shaderMaterial\n * @param onError\n * @returns callback when shader is compiled\n */\nconst onShaderCompileError = (program, shaderMaterial, onError) => {\n return (effect, error) => {\n shaderMaterial.dispose(true);\n onError(\"Cannot compile program named \" + program.name + \". Error: \" + error + \". Default material will be applied\");\n };\n};\n/**\n * Shader compilation success\n * @param gltfRuntime\n * @param shaderMaterial\n * @param technique\n * @param material\n * @param unTreatedUniforms\n * @param onSuccess\n * @returns callback when shader is compiled\n */\nconst onShaderCompileSuccess = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) => {\n return (_) => {\n prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);\n shaderMaterial.onBind = (mesh) => {\n onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);\n };\n };\n};\n/**\n * Returns the appropriate uniform if already handled by babylon\n * @param tokenizer\n * @param technique\n * @param unTreatedUniforms\n * @returns the name of the uniform handled by babylon\n */\nconst parseShaderUniforms = (tokenizer, technique, unTreatedUniforms) => {\n for (const unif in technique.uniforms) {\n const uniform = technique.uniforms[unif];\n const uniformParameter = technique.parameters[uniform];\n if (tokenizer.currentIdentifier === unif) {\n if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) {\n const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);\n if (transformIndex !== -1) {\n delete unTreatedUniforms[unif];\n return babylonTransforms[transformIndex];\n }\n }\n }\n }\n return tokenizer.currentIdentifier;\n};\n/**\n * All shaders loaded. Create materials one by one\n * @param gltfRuntime\n */\nconst importMaterials = (gltfRuntime) => {\n // Create materials\n for (const mat in gltfRuntime.materials) {\n GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, () => { }, () => { });\n }\n};\n/**\n * Implementation of the base glTF spec\n * @internal\n */\nexport class GLTFLoaderBase {\n static CreateRuntime(parsedData, scene, rootUrl) {\n const gltfRuntime = {\n extensions: {},\n accessors: {},\n buffers: {},\n bufferViews: {},\n meshes: {},\n lights: {},\n cameras: {},\n nodes: {},\n images: {},\n textures: {},\n shaders: {},\n programs: {},\n samplers: {},\n techniques: {},\n materials: {},\n animations: {},\n skins: {},\n extensionsUsed: [],\n scenes: {},\n buffersCount: 0,\n shaderscount: 0,\n scene: scene,\n rootUrl: rootUrl,\n loadedBufferCount: 0,\n loadedBufferViews: {},\n loadedShaderCount: 0,\n importOnlyMeshes: false,\n dummyNodes: [],\n assetContainer: null,\n };\n // Parse\n if (parsedData.extensions) {\n parseObject(parsedData.extensions, \"extensions\", gltfRuntime);\n }\n if (parsedData.extensionsUsed) {\n parseObject(parsedData.extensionsUsed, \"extensionsUsed\", gltfRuntime);\n }\n if (parsedData.buffers) {\n parseBuffers(parsedData.buffers, gltfRuntime);\n }\n if (parsedData.bufferViews) {\n parseObject(parsedData.bufferViews, \"bufferViews\", gltfRuntime);\n }\n if (parsedData.accessors) {\n parseObject(parsedData.accessors, \"accessors\", gltfRuntime);\n }\n if (parsedData.meshes) {\n parseObject(parsedData.meshes, \"meshes\", gltfRuntime);\n }\n if (parsedData.lights) {\n parseObject(parsedData.lights, \"lights\", gltfRuntime);\n }\n if (parsedData.cameras) {\n parseObject(parsedData.cameras, \"cameras\", gltfRuntime);\n }\n if (parsedData.nodes) {\n parseObject(parsedData.nodes, \"nodes\", gltfRuntime);\n }\n if (parsedData.images) {\n parseObject(parsedData.images, \"images\", gltfRuntime);\n }\n if (parsedData.textures) {\n parseObject(parsedData.textures, \"textures\", gltfRuntime);\n }\n if (parsedData.shaders) {\n parseShaders(parsedData.shaders, gltfRuntime);\n }\n if (parsedData.programs) {\n parseObject(parsedData.programs, \"programs\", gltfRuntime);\n }\n if (parsedData.samplers) {\n parseObject(parsedData.samplers, \"samplers\", gltfRuntime);\n }\n if (parsedData.techniques) {\n parseObject(parsedData.techniques, \"techniques\", gltfRuntime);\n }\n if (parsedData.materials) {\n parseObject(parsedData.materials, \"materials\", gltfRuntime);\n }\n if (parsedData.animations) {\n parseObject(parsedData.animations, \"animations\", gltfRuntime);\n }\n if (parsedData.skins) {\n parseObject(parsedData.skins, \"skins\", gltfRuntime);\n }\n if (parsedData.scenes) {\n gltfRuntime.scenes = parsedData.scenes;\n }\n if (parsedData.scene && parsedData.scenes) {\n gltfRuntime.currentScene = parsedData.scenes[parsedData.scene];\n }\n return gltfRuntime;\n }\n static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n const buffer = gltfRuntime.buffers[id];\n if (Tools.IsBase64(buffer.uri)) {\n setTimeout(() => onSuccess(new Uint8Array(Tools.DecodeBase64(buffer.uri))));\n }\n else {\n Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, (data) => onSuccess(new Uint8Array(data)), onProgress, undefined, true, (request) => {\n if (request) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n const texture = gltfRuntime.textures[id];\n if (!texture || !texture.source) {\n onError(\"\");\n return;\n }\n if (texture.babylonTexture) {\n onSuccess(null);\n return;\n }\n const source = gltfRuntime.images[texture.source];\n if (Tools.IsBase64(source.uri)) {\n setTimeout(() => onSuccess(new Uint8Array(Tools.DecodeBase64(source.uri))));\n }\n else {\n Tools.LoadFile(gltfRuntime.rootUrl + source.uri, (data) => onSuccess(new Uint8Array(data)), undefined, undefined, true, (request) => {\n if (request) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess) {\n const texture = gltfRuntime.textures[id];\n if (texture.babylonTexture) {\n onSuccess(texture.babylonTexture);\n return;\n }\n const sampler = gltfRuntime.samplers[texture.sampler];\n const createMipMaps = sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_NEAREST ||\n sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_LINEAR ||\n sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_NEAREST ||\n sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_LINEAR;\n const samplingMode = Texture.BILINEAR_SAMPLINGMODE;\n const blob = buffer == null ? new Blob() : new Blob([buffer]);\n const blobURL = URL.createObjectURL(blob);\n const revokeBlobURL = () => URL.revokeObjectURL(blobURL);\n const newTexture = new Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL);\n if (sampler.wrapS !== undefined) {\n newTexture.wrapU = GLTFUtils.GetWrapMode(sampler.wrapS);\n }\n if (sampler.wrapT !== undefined) {\n newTexture.wrapV = GLTFUtils.GetWrapMode(sampler.wrapT);\n }\n newTexture.name = id;\n texture.babylonTexture = newTexture;\n onSuccess(newTexture);\n }\n static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n const shader = gltfRuntime.shaders[id];\n if (Tools.IsBase64(shader.uri)) {\n const shaderString = atob(shader.uri.split(\",\")[1]);\n if (onSuccess) {\n onSuccess(shaderString);\n }\n }\n else {\n Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, (request) => {\n if (request && onError) {\n onError(request.status + \" \" + request.statusText);\n }\n });\n }\n }\n static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n const material = gltfRuntime.materials[id];\n if (!material.technique) {\n if (onError) {\n onError(\"No technique found.\");\n }\n return;\n }\n const technique = gltfRuntime.techniques[material.technique];\n if (!technique) {\n gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;\n const defaultMaterial = new StandardMaterial(id, gltfRuntime.scene);\n defaultMaterial._parentContainer = gltfRuntime.assetContainer;\n gltfRuntime.scene._blockEntityCollection = false;\n defaultMaterial.diffuseColor = new Color3(0.5, 0.5, 0.5);\n defaultMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n onSuccess(defaultMaterial);\n return;\n }\n const program = gltfRuntime.programs[technique.program];\n const states = technique.states;\n const vertexShader = Effect.ShadersStore[program.vertexShader + \"VertexShader\"];\n const pixelShader = Effect.ShadersStore[program.fragmentShader + \"PixelShader\"];\n let newVertexShader = \"\";\n let newPixelShader = \"\";\n const vertexTokenizer = new Tokenizer(vertexShader);\n const pixelTokenizer = new Tokenizer(pixelShader);\n const unTreatedUniforms = {};\n const uniforms = [];\n const attributes = [];\n const samplers = [];\n // Fill uniform, sampler2D and attributes\n for (const unif in technique.uniforms) {\n const uniform = technique.uniforms[unif];\n const uniformParameter = technique.parameters[uniform];\n unTreatedUniforms[unif] = uniformParameter;\n if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {\n const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);\n if (transformIndex !== -1) {\n uniforms.push(babylonTransforms[transformIndex]);\n delete unTreatedUniforms[unif];\n }\n else {\n uniforms.push(unif);\n }\n }\n else if (uniformParameter.type === EParameterType.SAMPLER_2D) {\n samplers.push(unif);\n }\n else {\n uniforms.push(unif);\n }\n }\n for (const attr in technique.attributes) {\n const attribute = technique.attributes[attr];\n const attributeParameter = technique.parameters[attribute];\n if (attributeParameter.semantic) {\n const name = getAttribute(attributeParameter);\n if (name) {\n attributes.push(name);\n }\n }\n }\n // Configure vertex shader\n while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) {\n const tokenType = vertexTokenizer.currentToken;\n if (tokenType !== ETokenType.IDENTIFIER) {\n newVertexShader += vertexTokenizer.currentString;\n continue;\n }\n let foundAttribute = false;\n for (const attr in technique.attributes) {\n const attribute = technique.attributes[attr];\n const attributeParameter = technique.parameters[attribute];\n if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {\n newVertexShader += getAttribute(attributeParameter);\n foundAttribute = true;\n break;\n }\n }\n if (foundAttribute) {\n continue;\n }\n newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);\n }\n // Configure pixel shader\n while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {\n const tokenType = pixelTokenizer.currentToken;\n if (tokenType !== ETokenType.IDENTIFIER) {\n newPixelShader += pixelTokenizer.currentString;\n continue;\n }\n newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);\n }\n // Create shader material\n const shaderPath = {\n vertex: program.vertexShader + id,\n fragment: program.fragmentShader + id,\n };\n const options = {\n attributes: attributes,\n uniforms: uniforms,\n samplers: samplers,\n needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1,\n };\n Effect.ShadersStore[program.vertexShader + id + \"VertexShader\"] = newVertexShader;\n Effect.ShadersStore[program.fragmentShader + id + \"PixelShader\"] = newPixelShader;\n const shaderMaterial = new ShaderMaterial(id, gltfRuntime.scene, shaderPath, options);\n shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError);\n shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);\n shaderMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n if (states && states.functions) {\n const functions = states.functions;\n if (functions.cullFace && functions.cullFace[0] !== ECullingType.BACK) {\n shaderMaterial.backFaceCulling = false;\n }\n const blendFunc = functions.blendFuncSeparate;\n if (blendFunc) {\n if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&\n blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_ALPHA &&\n blendFunc[2] === EBlendingFunction.ONE &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_COMBINE;\n }\n else if (blendFunc[0] === EBlendingFunction.ONE &&\n blendFunc[1] === EBlendingFunction.ONE &&\n blendFunc[2] === EBlendingFunction.ZERO &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_ONEONE;\n }\n else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&\n blendFunc[1] === EBlendingFunction.ONE &&\n blendFunc[2] === EBlendingFunction.ZERO &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_ADD;\n }\n else if (blendFunc[0] === EBlendingFunction.ZERO &&\n blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR &&\n blendFunc[2] === EBlendingFunction.ONE &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_SUBTRACT;\n }\n else if (blendFunc[0] === EBlendingFunction.DST_COLOR &&\n blendFunc[1] === EBlendingFunction.ZERO &&\n blendFunc[2] === EBlendingFunction.ONE &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_MULTIPLY;\n }\n else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&\n blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR &&\n blendFunc[2] === EBlendingFunction.ONE &&\n blendFunc[3] === EBlendingFunction.ONE) {\n shaderMaterial.alphaMode = Constants.ALPHA_MAXIMIZED;\n }\n }\n }\n }\n}\n/**\n * glTF V1 Loader\n * @internal\n * @deprecated\n */\nexport class GLTFLoader {\n static RegisterExtension(extension) {\n if (GLTFLoader.Extensions[extension.name]) {\n Tools.Error('Tool with the same name \"' + extension.name + '\" already exists');\n return;\n }\n GLTFLoader.Extensions[extension.name] = extension;\n }\n dispose() {\n // do nothing\n }\n _importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) {\n scene.useRightHandedSystem = true;\n GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, (gltfRuntime) => {\n gltfRuntime.assetContainer = assetContainer;\n gltfRuntime.importOnlyMeshes = true;\n if (meshesNames === \"\") {\n gltfRuntime.importMeshesNames = [];\n }\n else if (typeof meshesNames === \"string\") {\n gltfRuntime.importMeshesNames = [meshesNames];\n }\n else if (meshesNames && !(meshesNames instanceof Array)) {\n gltfRuntime.importMeshesNames = [meshesNames];\n }\n else {\n gltfRuntime.importMeshesNames = [];\n Tools.Warn(\"Argument meshesNames must be of type string or string[]\");\n }\n // Create nodes\n this._createNodes(gltfRuntime);\n const meshes = [];\n const skeletons = [];\n // Fill arrays of meshes and skeletons\n for (const nde in gltfRuntime.nodes) {\n const node = gltfRuntime.nodes[nde];\n if (node.babylonNode instanceof AbstractMesh) {\n meshes.push(node.babylonNode);\n }\n }\n for (const skl in gltfRuntime.skins) {\n const skin = gltfRuntime.skins[skl];\n if (skin.babylonSkeleton instanceof Skeleton) {\n skeletons.push(skin.babylonSkeleton);\n }\n }\n // Load buffers, shaders, materials, etc.\n this._loadBuffersAsync(gltfRuntime, () => {\n this._loadShadersAsync(gltfRuntime, () => {\n importMaterials(gltfRuntime);\n postLoad(gltfRuntime);\n if (!GLTFFileLoader.IncrementalLoading && onSuccess) {\n onSuccess(meshes, skeletons);\n }\n });\n });\n if (GLTFFileLoader.IncrementalLoading && onSuccess) {\n onSuccess(meshes, skeletons);\n }\n }, onError);\n return true;\n }\n /**\n * Imports one or more meshes from a loaded gltf file and adds them to the scene\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\n * @param scene the scene the meshes should be added to\n * @param assetContainer defines the asset container to use (can be null)\n * @param data gltf data containing information of the meshes in a loaded file\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @returns a promise containg the loaded meshes, particles, skeletons and animations\n */\n importMeshAsync(meshesNames, scene, assetContainer, data, rootUrl, onProgress) {\n return new Promise((resolve, reject) => {\n this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, (meshes, skeletons) => {\n resolve({\n meshes: meshes,\n particleSystems: [],\n skeletons: skeletons,\n animationGroups: [],\n lights: [],\n transformNodes: [],\n geometries: [],\n spriteManagers: [],\n });\n }, onProgress, (message) => {\n reject(new Error(message));\n });\n });\n }\n _loadAsync(scene, data, rootUrl, onSuccess, onProgress, onError) {\n scene.useRightHandedSystem = true;\n GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, (gltfRuntime) => {\n // Load runtime extensios\n GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, () => {\n // Create nodes\n this._createNodes(gltfRuntime);\n // Load buffers, shaders, materials, etc.\n this._loadBuffersAsync(gltfRuntime, () => {\n this._loadShadersAsync(gltfRuntime, () => {\n importMaterials(gltfRuntime);\n postLoad(gltfRuntime);\n if (!GLTFFileLoader.IncrementalLoading) {\n onSuccess();\n }\n });\n });\n if (GLTFFileLoader.IncrementalLoading) {\n onSuccess();\n }\n }, onError);\n }, onError);\n }\n /**\n * Imports all objects from a loaded gltf file and adds them to the scene\n * @param scene the scene the objects should be added to\n * @param data gltf data containing information of the meshes in a loaded file\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @returns a promise which completes when objects have been loaded to the scene\n */\n loadAsync(scene, data, rootUrl, onProgress) {\n return new Promise((resolve, reject) => {\n this._loadAsync(scene, data, rootUrl, () => {\n resolve();\n }, onProgress, (message) => {\n reject(new Error(message));\n });\n });\n }\n _loadShadersAsync(gltfRuntime, onload) {\n let hasShaders = false;\n const processShader = (sha, shader) => {\n GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, (shaderString) => {\n if (shaderString instanceof ArrayBuffer) {\n return;\n }\n gltfRuntime.loadedShaderCount++;\n if (shaderString) {\n Effect.ShadersStore[sha + (shader.type === EShaderType.VERTEX ? \"VertexShader\" : \"PixelShader\")] = shaderString;\n }\n if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) {\n onload();\n }\n }, () => {\n Tools.Error(\"Error when loading shader program named \" + sha + \" located at \" + shader.uri);\n });\n };\n for (const sha in gltfRuntime.shaders) {\n hasShaders = true;\n const shader = gltfRuntime.shaders[sha];\n if (shader) {\n processShader.bind(this, sha, shader)();\n }\n else {\n Tools.Error(\"No shader named: \" + sha);\n }\n }\n if (!hasShaders) {\n onload();\n }\n }\n _loadBuffersAsync(gltfRuntime, onLoad) {\n let hasBuffers = false;\n const processBuffer = (buf, buffer) => {\n GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, (bufferView) => {\n gltfRuntime.loadedBufferCount++;\n if (bufferView) {\n if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) {\n Tools.Error(\"Buffer named \" + buf + \" is length \" + bufferView.byteLength + \". Expected: \" + buffer.byteLength); // Improve error message\n }\n gltfRuntime.loadedBufferViews[buf] = bufferView;\n }\n if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) {\n onLoad();\n }\n }, () => {\n Tools.Error(\"Error when loading buffer named \" + buf + \" located at \" + buffer.uri);\n });\n };\n for (const buf in gltfRuntime.buffers) {\n hasBuffers = true;\n const buffer = gltfRuntime.buffers[buf];\n if (buffer) {\n processBuffer.bind(this, buf, buffer)();\n }\n else {\n Tools.Error(\"No buffer named: \" + buf);\n }\n }\n if (!hasBuffers) {\n onLoad();\n }\n }\n _createNodes(gltfRuntime) {\n let currentScene = gltfRuntime.currentScene;\n if (currentScene) {\n // Only one scene even if multiple scenes are defined\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n else {\n // Load all scenes\n for (const thing in gltfRuntime.scenes) {\n currentScene = gltfRuntime.scenes[thing];\n for (let i = 0; i < currentScene.nodes.length; i++) {\n traverseNodes(gltfRuntime, currentScene.nodes[i], null);\n }\n }\n }\n }\n}\nGLTFLoader.Extensions = {};\n/** @internal */\nexport class GLTFLoaderExtension {\n constructor(name) {\n this._name = name;\n }\n get name() {\n return this._name;\n }\n /**\n * Defines an override for loading the runtime\n * Return true to stop further extensions from loading the runtime\n * @param scene\n * @param data\n * @param rootUrl\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading the runtime\n */\n loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an onverride for creating gltf runtime\n * Return true to stop further extensions from creating the runtime\n * @param gltfRuntime\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from creating the runtime\n */\n loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading buffers\n * Return true to stop further extensions from loading this buffer\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @param onProgress\n * @returns true to stop further extensions from loading this buffer\n */\n loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n return false;\n }\n /**\n * Defines an override for loading texture buffers\n * Return true to stop further extensions from loading this texture data\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this texture data\n */\n loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for creating textures\n * Return true to stop further extensions from loading this texture\n * @param gltfRuntime\n * @param id\n * @param buffer\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this texture\n */\n createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading shader strings\n * Return true to stop further extensions from loading this shader data\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this shader data\n */\n loadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n /**\n * Defines an override for loading materials\n * Return true to stop further extensions from loading this material\n * @param gltfRuntime\n * @param id\n * @param onSuccess\n * @param onError\n * @returns true to stop further extensions from loading this material\n */\n loadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n return false;\n }\n // ---------\n // Utilities\n // ---------\n static LoadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);\n }, () => {\n setTimeout(() => {\n if (!onSuccess) {\n return;\n }\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\n });\n });\n }\n static LoadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);\n }, () => {\n setTimeout(() => {\n onSuccess();\n });\n });\n }\n static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);\n }, () => {\n GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);\n });\n }\n static LoadTextureAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, (buffer) => {\n if (buffer) {\n GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);\n }\n }, onError);\n }\n static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static _LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);\n });\n }\n static _CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {\n GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {\n return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);\n }, () => {\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess);\n });\n }\n static _ApplyExtensions(func, defaultFunc) {\n for (const extensionName in GLTFLoader.Extensions) {\n const loaderExtension = GLTFLoader.Extensions[extensionName];\n if (func(loaderExtension)) {\n return;\n }\n }\n defaultFunc();\n }\n}\nGLTFFileLoader._CreateGLTF1Loader = () => new GLTFLoader();\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,kBAAkB,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,WAAW,QAAQ,2BAA2B;AAC5H,SAASC,UAAU,EAAEC,OAAO,EAAEC,MAAM,QAAQ,sCAAsC;AAClF,SAASC,MAAM,QAAQ,qCAAqC;AAC5D,SAASC,KAAK,QAAQ,+BAA+B;AACrD,SAASC,MAAM,QAAQ,mCAAmC;AAC1D,SAASC,UAAU,QAAQ,uCAAuC;AAClE,SAASC,SAAS,QAAQ,yCAAyC;AACnE,SAASC,IAAI,QAAQ,+BAA+B;AACpD,SAASC,QAAQ,QAAQ,mCAAmC;AAC5D,SAASC,MAAM,QAAQ,qCAAqC;AAC5D,SAASC,QAAQ,QAAQ,uCAAuC;AAChE,SAASC,aAAa,QAAQ,4CAA4C;AAC1E,SAASC,gBAAgB,QAAQ,+CAA+C;AAChF,SAASC,cAAc,QAAQ,6CAA6C;AAC5E,SAASC,OAAO,QAAQ,+CAA+C;AACvE,SAASC,UAAU,QAAQ,2CAA2C;AACtE,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,QAAQ,QAAQ,oCAAoC;AAC7D,SAASC,OAAO,QAAQ,mCAAmC;AAC3D,SAASC,YAAY,QAAQ,wCAAwC;AACrE,SAASC,IAAI,QAAQ,gCAAgC;AACrD,SAASC,gBAAgB,QAA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