{"ast":null,"code":"import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from \"./glTFLoader.js\";\nimport { Vector3 } 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 { Material } from \"@babylonjs/core/Materials/material.js\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial.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\";\n/**\n * @internal\n * @deprecated\n */\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\n constructor() {\n super(\"KHR_materials_common\");\n }\n loadRuntimeExtensionsAsync(gltfRuntime) {\n if (!gltfRuntime.extensions) {\n return false;\n }\n const extension = gltfRuntime.extensions[this.name];\n if (!extension) {\n return false;\n }\n // Create lights\n const lights = extension.lights;\n if (lights) {\n for (const thing in lights) {\n const light = lights[thing];\n switch (light.type) {\n case \"ambient\":\n {\n const ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\n const ambient = light.ambient;\n if (ambient) {\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\n }\n break;\n }\n case \"point\":\n {\n const pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\n const point = light.point;\n if (point) {\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\n }\n break;\n }\n case \"directional\":\n {\n const dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\n const directional = light.directional;\n if (directional) {\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\n }\n break;\n }\n case \"spot\":\n {\n const spot = light.spot;\n if (spot) {\n const spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\n }\n break;\n }\n default:\n Tools.Warn('GLTF Material Common extension: light type \"' + light.type + \"” not supported\");\n break;\n }\n }\n }\n return false;\n }\n loadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n const material = gltfRuntime.materials[id];\n if (!material || !material.extensions) {\n return false;\n }\n const extension = material.extensions[this.name];\n if (!extension) {\n return false;\n }\n const standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n if (extension.technique === \"CONSTANT\") {\n standardMaterial.disableLighting = true;\n }\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\n // Ambient\n if (typeof extension.values.ambient === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\n } else {\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\n }\n // Diffuse\n if (typeof extension.values.diffuse === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\n } else {\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\n }\n // Emission\n if (typeof extension.values.emission === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\n } else {\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\n }\n // Specular\n if (typeof extension.values.specular === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\n } else {\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\n }\n return true;\n }\n _loadTexture(gltfRuntime, id, material, propertyPath, onError) {\n // Create buffer from texture url\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, buffer => {\n // Create texture from buffer\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, texture => material[propertyPath] = texture);\n }, onError);\n }\n}\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());","map":{"version":3,"names":["GLTFLoaderExtension","GLTFLoaderBase","GLTFLoader","Vector3","Color3","Tools","Material","StandardMaterial","HemisphericLight","DirectionalLight","PointLight","SpotLight","GLTFMaterialsCommonExtension","constructor","loadRuntimeExtensionsAsync","gltfRuntime","extensions","extension","name","lights","thing","light","type","ambientLight","scene","ambient","diffuse","FromArray","color","pointLight","point","dirLight","directional","spot","spotLight","fallOffAngle","Math","PI","fallOffExponent","Warn","loadMaterialAsync","id","onSuccess","onError","material","materials","standardMaterial","sideOrientation","CounterClockWiseSideOrientation","technique","disableLighting","backFaceCulling","doubleSided","undefined","alpha","values","transparency","specularPower","shininess","_loadTexture","ambientColor","diffuseColor","emission","emissiveColor","specular","specularColor","propertyPath","LoadTextureBufferAsync","buffer","CreateTextureAsync","texture","RegisterExtension"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/1.0/glTFMaterialsCommonExtension.js"],"sourcesContent":["import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from \"./glTFLoader.js\";\nimport { Vector3 } 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 { Material } from \"@babylonjs/core/Materials/material.js\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial.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\";\n/**\n * @internal\n * @deprecated\n */\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\n constructor() {\n super(\"KHR_materials_common\");\n }\n loadRuntimeExtensionsAsync(gltfRuntime) {\n if (!gltfRuntime.extensions) {\n return false;\n }\n const extension = gltfRuntime.extensions[this.name];\n if (!extension) {\n return false;\n }\n // Create lights\n const lights = extension.lights;\n if (lights) {\n for (const thing in lights) {\n const light = lights[thing];\n switch (light.type) {\n case \"ambient\": {\n const ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\n const ambient = light.ambient;\n if (ambient) {\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\n }\n break;\n }\n case \"point\": {\n const pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\n const point = light.point;\n if (point) {\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\n }\n break;\n }\n case \"directional\": {\n const dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\n const directional = light.directional;\n if (directional) {\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\n }\n break;\n }\n case \"spot\": {\n const spot = light.spot;\n if (spot) {\n const spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\n }\n break;\n }\n default:\n Tools.Warn('GLTF Material Common extension: light type \"' + light.type + \"” not supported\");\n break;\n }\n }\n }\n return false;\n }\n loadMaterialAsync(gltfRuntime, id, onSuccess, onError) {\n const material = gltfRuntime.materials[id];\n if (!material || !material.extensions) {\n return false;\n }\n const extension = material.extensions[this.name];\n if (!extension) {\n return false;\n }\n const standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n if (extension.technique === \"CONSTANT\") {\n standardMaterial.disableLighting = true;\n }\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\n // Ambient\n if (typeof extension.values.ambient === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\n }\n else {\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\n }\n // Diffuse\n if (typeof extension.values.diffuse === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\n }\n else {\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\n }\n // Emission\n if (typeof extension.values.emission === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\n }\n else {\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\n }\n // Specular\n if (typeof extension.values.specular === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\n }\n else {\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\n }\n return true;\n }\n _loadTexture(gltfRuntime, id, material, propertyPath, onError) {\n // Create buffer from texture url\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, (buffer) => {\n // Create texture from buffer\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, (texture) => (material[propertyPath] = texture));\n }, onError);\n }\n}\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());\n"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAiB;AACjF,SAASC,OAAO,QAAQ,sCAAsC;AAC9D,SAASC,MAAM,QAAQ,qCAAqC;AAC5D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