three-stdlib 2.23.5 → 2.23.7
Sign up to get free protection for your applications and to get access to all the features.
- package/_polyfill/CapsuleGeometry.cjs +22 -0
- package/_polyfill/CapsuleGeometry.js +22 -0
- package/animation/MMDPhysics.cjs +2 -1
- package/animation/MMDPhysics.js +2 -1
- package/exporters/GLTFExporter.cjs +1 -1
- package/exporters/GLTFExporter.js +2 -2
- package/loaders/GLTFLoader.cjs +30 -20
- package/loaders/GLTFLoader.js +31 -21
- package/package.json +1 -1
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const THREE = require("three");
|
4
|
+
class CapsuleGeometry extends THREE.LatheGeometry {
|
5
|
+
constructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) {
|
6
|
+
const path = new THREE.Path();
|
7
|
+
path.absarc(0, -length / 2, radius, Math.PI * 1.5, 0);
|
8
|
+
path.absarc(0, length / 2, radius, 0, Math.PI * 0.5);
|
9
|
+
super(path.getPoints(capSegments), radialSegments);
|
10
|
+
this.type = "CapsuleGeometry";
|
11
|
+
this.parameters = {
|
12
|
+
radius,
|
13
|
+
height: length,
|
14
|
+
capSegments,
|
15
|
+
radialSegments
|
16
|
+
};
|
17
|
+
}
|
18
|
+
static fromJSON(data) {
|
19
|
+
return new CapsuleGeometry(data.radius, data.length, data.capSegments, data.radialSegments);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
exports.CapsuleGeometry = CapsuleGeometry;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { LatheGeometry, Path } from "three";
|
2
|
+
class CapsuleGeometry extends LatheGeometry {
|
3
|
+
constructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) {
|
4
|
+
const path = new Path();
|
5
|
+
path.absarc(0, -length / 2, radius, Math.PI * 1.5, 0);
|
6
|
+
path.absarc(0, length / 2, radius, 0, Math.PI * 0.5);
|
7
|
+
super(path.getPoints(capSegments), radialSegments);
|
8
|
+
this.type = "CapsuleGeometry";
|
9
|
+
this.parameters = {
|
10
|
+
radius,
|
11
|
+
height: length,
|
12
|
+
capSegments,
|
13
|
+
radialSegments
|
14
|
+
};
|
15
|
+
}
|
16
|
+
static fromJSON(data) {
|
17
|
+
return new CapsuleGeometry(data.radius, data.length, data.capSegments, data.radialSegments);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
export {
|
21
|
+
CapsuleGeometry
|
22
|
+
};
|
package/animation/MMDPhysics.cjs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
3
|
const THREE = require("three");
|
4
|
+
const CapsuleGeometry = require("../_polyfill/CapsuleGeometry.cjs");
|
4
5
|
class MMDPhysics {
|
5
6
|
/**
|
6
7
|
* @param {THREE.SkinnedMesh} mesh
|
@@ -815,7 +816,7 @@ class MMDPhysicsHelper extends THREE.Object3D {
|
|
815
816
|
case 1:
|
816
817
|
return new THREE.BoxGeometry(param2.width * 2, param2.height * 2, param2.depth * 2, 8, 8, 8);
|
817
818
|
case 2:
|
818
|
-
return new
|
819
|
+
return new CapsuleGeometry.CapsuleGeometry(param2.width, param2.height, 8, 16);
|
819
820
|
default:
|
820
821
|
return null;
|
821
822
|
}
|
package/animation/MMDPhysics.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Vector3, Matrix4, Quaternion, Euler, Bone, Object3D, MeshBasicMaterial, Color,
|
1
|
+
import { Vector3, Matrix4, Quaternion, Euler, Bone, Object3D, MeshBasicMaterial, Color, BoxGeometry, SphereGeometry, Mesh } from "three";
|
2
|
+
import { CapsuleGeometry } from "../_polyfill/CapsuleGeometry.js";
|
2
3
|
class MMDPhysics {
|
3
4
|
/**
|
4
5
|
* @param {THREE.SkinnedMesh} mesh
|
@@ -560,7 +560,7 @@ class GLTFWriter {
|
|
560
560
|
context.putImageData(composite, 0, 0);
|
561
561
|
const reference = metalnessMap || roughnessMap;
|
562
562
|
const texture = reference.clone();
|
563
|
-
texture.source = new THREE.
|
563
|
+
texture.source = new THREE.Texture(canvas).source;
|
564
564
|
if ("colorSpace" in texture)
|
565
565
|
texture.colorSpace = "";
|
566
566
|
else
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PlaneGeometry, ShaderMaterial, Uniform, Mesh, PerspectiveCamera, Scene, WebGLRenderer, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, RepeatWrapping, MirroredRepeatWrapping, Color, MathUtils, Vector3, CompressedTexture,
|
1
|
+
import { PlaneGeometry, ShaderMaterial, Uniform, Mesh, PerspectiveCamera, Scene, WebGLRenderer, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, RepeatWrapping, MirroredRepeatWrapping, Color, MathUtils, Vector3, CompressedTexture, RGBAFormat, DoubleSide, REVISION, BufferAttribute, PropertyBinding, InterpolateDiscrete, Matrix4, InterpolateLinear } from "three";
|
2
2
|
let _renderer;
|
3
3
|
let fullscreenQuadGeometry;
|
4
4
|
let fullscreenQuadMaterial;
|
@@ -558,7 +558,7 @@ class GLTFWriter {
|
|
558
558
|
context.putImageData(composite, 0, 0);
|
559
559
|
const reference = metalnessMap || roughnessMap;
|
560
560
|
const texture = reference.clone();
|
561
|
-
texture.source = new
|
561
|
+
texture.source = new Texture(canvas).source;
|
562
562
|
if ("colorSpace" in texture)
|
563
563
|
texture.colorSpace = "";
|
564
564
|
else
|
package/loaders/GLTFLoader.cjs
CHANGED
@@ -132,11 +132,10 @@ class GLTFLoader extends THREE.Loader {
|
|
132
132
|
let json;
|
133
133
|
const extensions = {};
|
134
134
|
const plugins = {};
|
135
|
-
const textDecoder = new TextDecoder();
|
136
135
|
if (typeof data === "string") {
|
137
136
|
json = JSON.parse(data);
|
138
137
|
} else if (data instanceof ArrayBuffer) {
|
139
|
-
const magic =
|
138
|
+
const magic = THREE.LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4)));
|
140
139
|
if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
|
141
140
|
try {
|
142
141
|
extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
|
@@ -147,7 +146,7 @@ class GLTFLoader extends THREE.Loader {
|
|
147
146
|
}
|
148
147
|
json = JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content);
|
149
148
|
} else {
|
150
|
-
json = JSON.parse(
|
149
|
+
json = JSON.parse(THREE.LoaderUtils.decodeText(new Uint8Array(data)));
|
151
150
|
}
|
152
151
|
} else {
|
153
152
|
json = data;
|
@@ -348,7 +347,7 @@ class GLTFMaterialsUnlitExtension {
|
|
348
347
|
materialParams.opacity = array[3];
|
349
348
|
}
|
350
349
|
if (metallicRoughness.baseColorTexture !== void 0) {
|
351
|
-
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture,
|
350
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
|
352
351
|
}
|
353
352
|
}
|
354
353
|
return Promise.all(pending);
|
@@ -490,7 +489,7 @@ class GLTFMaterialsSheenExtension {
|
|
490
489
|
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
491
490
|
}
|
492
491
|
if (extension.sheenColorTexture !== void 0) {
|
493
|
-
pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture,
|
492
|
+
pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture, 3001));
|
494
493
|
}
|
495
494
|
if (extension.sheenRoughnessTexture !== void 0) {
|
496
495
|
pending.push(parser.assignTexture(materialParams, "sheenRoughnessMap", extension.sheenRoughnessTexture));
|
@@ -608,7 +607,8 @@ class GLTFMaterialsSpecularExtension {
|
|
608
607
|
materialParams.specularColor = new THREE.Color(colorArray[0], colorArray[1], colorArray[2]);
|
609
608
|
if (extension.specularColorTexture !== void 0) {
|
610
609
|
pending.push(
|
611
|
-
parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture,
|
610
|
+
parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture, 3001)
|
611
|
+
// sRGBEncoding
|
612
612
|
);
|
613
613
|
}
|
614
614
|
return Promise.all(pending);
|
@@ -890,9 +890,8 @@ class GLTFBinaryExtension {
|
|
890
890
|
this.content = null;
|
891
891
|
this.body = null;
|
892
892
|
const headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
|
893
|
-
const textDecoder = new TextDecoder();
|
894
893
|
this.header = {
|
895
|
-
magic:
|
894
|
+
magic: THREE.LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
|
896
895
|
version: headerView.getUint32(4, true),
|
897
896
|
length: headerView.getUint32(8, true)
|
898
897
|
};
|
@@ -911,7 +910,7 @@ class GLTFBinaryExtension {
|
|
911
910
|
chunkIndex += 4;
|
912
911
|
if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
|
913
912
|
const contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
|
914
|
-
this.content =
|
913
|
+
this.content = THREE.LoaderUtils.decodeText(contentArray);
|
915
914
|
} else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
|
916
915
|
const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
|
917
916
|
this.body = data.slice(byteOffset, byteOffset + chunkLength);
|
@@ -1041,7 +1040,7 @@ class GLTFCubicSplineInterpolant extends THREE.Interpolant {
|
|
1041
1040
|
return result;
|
1042
1041
|
}
|
1043
1042
|
}
|
1044
|
-
const _q = new THREE.Quaternion();
|
1043
|
+
const _q = /* @__PURE__ */ new THREE.Quaternion();
|
1045
1044
|
class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
1046
1045
|
interpolate_(i1, t0, t, t1) {
|
1047
1046
|
const result = super.interpolate_(i1, t0, t, t1);
|
@@ -1104,10 +1103,18 @@ const ATTRIBUTES = {
|
|
1104
1103
|
POSITION: "position",
|
1105
1104
|
NORMAL: "normal",
|
1106
1105
|
TANGENT: "tangent",
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1106
|
+
// uv => uv1, 4 uv channels
|
1107
|
+
// https://github.com/mrdoob/three.js/pull/25943
|
1108
|
+
// https://github.com/mrdoob/three.js/pull/25788
|
1109
|
+
...THREE.REVISION.replace(/\D+/g, "") >= 152 ? {
|
1110
|
+
TEXCOORD_0: "uv",
|
1111
|
+
TEXCOORD_1: "uv1",
|
1112
|
+
TEXCOORD_2: "uv2",
|
1113
|
+
TEXCOORD_3: "uv3"
|
1114
|
+
} : {
|
1115
|
+
TEXCOORD_0: "uv",
|
1116
|
+
TEXCOORD_1: "uv2"
|
1117
|
+
},
|
1111
1118
|
COLOR_0: "color",
|
1112
1119
|
WEIGHTS_0: "skinWeight",
|
1113
1120
|
JOINTS_0: "skinIndex"
|
@@ -1277,7 +1284,7 @@ function getImageURIMimeType(uri) {
|
|
1277
1284
|
return "image/webp";
|
1278
1285
|
return "image/png";
|
1279
1286
|
}
|
1280
|
-
const _identityMatrix = new THREE.Matrix4();
|
1287
|
+
const _identityMatrix = /* @__PURE__ */ new THREE.Matrix4();
|
1281
1288
|
class GLTFParser {
|
1282
1289
|
constructor(json = {}, options = {}) {
|
1283
1290
|
this.json = json;
|
@@ -1759,7 +1766,7 @@ class GLTFParser {
|
|
1759
1766
|
* @param {Object} mapDef
|
1760
1767
|
* @return {Promise<Texture>}
|
1761
1768
|
*/
|
1762
|
-
assignTexture(materialParams, mapName, mapDef,
|
1769
|
+
assignTexture(materialParams, mapName, mapDef, encoding) {
|
1763
1770
|
const parser = this;
|
1764
1771
|
return this.getDependency("texture", mapDef.index).then(function(texture) {
|
1765
1772
|
if (!texture)
|
@@ -1776,8 +1783,11 @@ class GLTFParser {
|
|
1776
1783
|
parser.associations.set(texture, gltfReference);
|
1777
1784
|
}
|
1778
1785
|
}
|
1779
|
-
if (
|
1780
|
-
|
1786
|
+
if (encoding !== void 0) {
|
1787
|
+
if ("colorSpace" in texture)
|
1788
|
+
texture.colorSpace = encoding === 3001 ? "srgb" : "srgb-linear";
|
1789
|
+
else
|
1790
|
+
texture.encoding = encoding;
|
1781
1791
|
}
|
1782
1792
|
materialParams[mapName] = texture;
|
1783
1793
|
return texture;
|
@@ -1880,7 +1890,7 @@ class GLTFParser {
|
|
1880
1890
|
materialParams.opacity = array[3];
|
1881
1891
|
}
|
1882
1892
|
if (metallicRoughness.baseColorTexture !== void 0) {
|
1883
|
-
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture,
|
1893
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
|
1884
1894
|
}
|
1885
1895
|
materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
|
1886
1896
|
materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
|
@@ -1930,7 +1940,7 @@ class GLTFParser {
|
|
1930
1940
|
materialParams.emissive = new THREE.Color().fromArray(materialDef.emissiveFactor);
|
1931
1941
|
}
|
1932
1942
|
if (materialDef.emissiveTexture !== void 0 && materialType !== THREE.MeshBasicMaterial) {
|
1933
|
-
pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture,
|
1943
|
+
pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture, 3001));
|
1934
1944
|
}
|
1935
1945
|
return Promise.all(pending).then(function() {
|
1936
1946
|
const material = new materialType(materialParams);
|
package/loaders/GLTFLoader.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial,
|
1
|
+
import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, Object3D, Interpolant, NearestFilter, LinearFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, RepeatWrapping, REVISION, InterpolateLinear, InterpolateDiscrete, MeshStandardMaterial, FrontSide, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, Texture, PointsMaterial, Material, LineBasicMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, AnimationClip, Bone, Box3, Sphere } from "three";
|
2
2
|
import { toTrianglesDrawMode } from "../utils/BufferGeometryUtils.js";
|
3
3
|
class GLTFLoader extends Loader {
|
4
4
|
constructor(manager) {
|
@@ -130,11 +130,10 @@ class GLTFLoader extends Loader {
|
|
130
130
|
let json;
|
131
131
|
const extensions = {};
|
132
132
|
const plugins = {};
|
133
|
-
const textDecoder = new TextDecoder();
|
134
133
|
if (typeof data === "string") {
|
135
134
|
json = JSON.parse(data);
|
136
135
|
} else if (data instanceof ArrayBuffer) {
|
137
|
-
const magic =
|
136
|
+
const magic = LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4)));
|
138
137
|
if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
|
139
138
|
try {
|
140
139
|
extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
|
@@ -145,7 +144,7 @@ class GLTFLoader extends Loader {
|
|
145
144
|
}
|
146
145
|
json = JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content);
|
147
146
|
} else {
|
148
|
-
json = JSON.parse(
|
147
|
+
json = JSON.parse(LoaderUtils.decodeText(new Uint8Array(data)));
|
149
148
|
}
|
150
149
|
} else {
|
151
150
|
json = data;
|
@@ -346,7 +345,7 @@ class GLTFMaterialsUnlitExtension {
|
|
346
345
|
materialParams.opacity = array[3];
|
347
346
|
}
|
348
347
|
if (metallicRoughness.baseColorTexture !== void 0) {
|
349
|
-
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture,
|
348
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
|
350
349
|
}
|
351
350
|
}
|
352
351
|
return Promise.all(pending);
|
@@ -488,7 +487,7 @@ class GLTFMaterialsSheenExtension {
|
|
488
487
|
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
489
488
|
}
|
490
489
|
if (extension.sheenColorTexture !== void 0) {
|
491
|
-
pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture,
|
490
|
+
pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture, 3001));
|
492
491
|
}
|
493
492
|
if (extension.sheenRoughnessTexture !== void 0) {
|
494
493
|
pending.push(parser.assignTexture(materialParams, "sheenRoughnessMap", extension.sheenRoughnessTexture));
|
@@ -606,7 +605,8 @@ class GLTFMaterialsSpecularExtension {
|
|
606
605
|
materialParams.specularColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
|
607
606
|
if (extension.specularColorTexture !== void 0) {
|
608
607
|
pending.push(
|
609
|
-
parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture,
|
608
|
+
parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture, 3001)
|
609
|
+
// sRGBEncoding
|
610
610
|
);
|
611
611
|
}
|
612
612
|
return Promise.all(pending);
|
@@ -888,9 +888,8 @@ class GLTFBinaryExtension {
|
|
888
888
|
this.content = null;
|
889
889
|
this.body = null;
|
890
890
|
const headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
|
891
|
-
const textDecoder = new TextDecoder();
|
892
891
|
this.header = {
|
893
|
-
magic:
|
892
|
+
magic: LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
|
894
893
|
version: headerView.getUint32(4, true),
|
895
894
|
length: headerView.getUint32(8, true)
|
896
895
|
};
|
@@ -909,7 +908,7 @@ class GLTFBinaryExtension {
|
|
909
908
|
chunkIndex += 4;
|
910
909
|
if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
|
911
910
|
const contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
|
912
|
-
this.content =
|
911
|
+
this.content = LoaderUtils.decodeText(contentArray);
|
913
912
|
} else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
|
914
913
|
const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
|
915
914
|
this.body = data.slice(byteOffset, byteOffset + chunkLength);
|
@@ -1039,7 +1038,7 @@ class GLTFCubicSplineInterpolant extends Interpolant {
|
|
1039
1038
|
return result;
|
1040
1039
|
}
|
1041
1040
|
}
|
1042
|
-
const _q = new Quaternion();
|
1041
|
+
const _q = /* @__PURE__ */ new Quaternion();
|
1043
1042
|
class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
1044
1043
|
interpolate_(i1, t0, t, t1) {
|
1045
1044
|
const result = super.interpolate_(i1, t0, t, t1);
|
@@ -1102,10 +1101,18 @@ const ATTRIBUTES = {
|
|
1102
1101
|
POSITION: "position",
|
1103
1102
|
NORMAL: "normal",
|
1104
1103
|
TANGENT: "tangent",
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1104
|
+
// uv => uv1, 4 uv channels
|
1105
|
+
// https://github.com/mrdoob/three.js/pull/25943
|
1106
|
+
// https://github.com/mrdoob/three.js/pull/25788
|
1107
|
+
...REVISION.replace(/\D+/g, "") >= 152 ? {
|
1108
|
+
TEXCOORD_0: "uv",
|
1109
|
+
TEXCOORD_1: "uv1",
|
1110
|
+
TEXCOORD_2: "uv2",
|
1111
|
+
TEXCOORD_3: "uv3"
|
1112
|
+
} : {
|
1113
|
+
TEXCOORD_0: "uv",
|
1114
|
+
TEXCOORD_1: "uv2"
|
1115
|
+
},
|
1109
1116
|
COLOR_0: "color",
|
1110
1117
|
WEIGHTS_0: "skinWeight",
|
1111
1118
|
JOINTS_0: "skinIndex"
|
@@ -1275,7 +1282,7 @@ function getImageURIMimeType(uri) {
|
|
1275
1282
|
return "image/webp";
|
1276
1283
|
return "image/png";
|
1277
1284
|
}
|
1278
|
-
const _identityMatrix = new Matrix4();
|
1285
|
+
const _identityMatrix = /* @__PURE__ */ new Matrix4();
|
1279
1286
|
class GLTFParser {
|
1280
1287
|
constructor(json = {}, options = {}) {
|
1281
1288
|
this.json = json;
|
@@ -1757,7 +1764,7 @@ class GLTFParser {
|
|
1757
1764
|
* @param {Object} mapDef
|
1758
1765
|
* @return {Promise<Texture>}
|
1759
1766
|
*/
|
1760
|
-
assignTexture(materialParams, mapName, mapDef,
|
1767
|
+
assignTexture(materialParams, mapName, mapDef, encoding) {
|
1761
1768
|
const parser = this;
|
1762
1769
|
return this.getDependency("texture", mapDef.index).then(function(texture) {
|
1763
1770
|
if (!texture)
|
@@ -1774,8 +1781,11 @@ class GLTFParser {
|
|
1774
1781
|
parser.associations.set(texture, gltfReference);
|
1775
1782
|
}
|
1776
1783
|
}
|
1777
|
-
if (
|
1778
|
-
|
1784
|
+
if (encoding !== void 0) {
|
1785
|
+
if ("colorSpace" in texture)
|
1786
|
+
texture.colorSpace = encoding === 3001 ? "srgb" : "srgb-linear";
|
1787
|
+
else
|
1788
|
+
texture.encoding = encoding;
|
1779
1789
|
}
|
1780
1790
|
materialParams[mapName] = texture;
|
1781
1791
|
return texture;
|
@@ -1878,7 +1888,7 @@ class GLTFParser {
|
|
1878
1888
|
materialParams.opacity = array[3];
|
1879
1889
|
}
|
1880
1890
|
if (metallicRoughness.baseColorTexture !== void 0) {
|
1881
|
-
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture,
|
1891
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
|
1882
1892
|
}
|
1883
1893
|
materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
|
1884
1894
|
materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
|
@@ -1928,7 +1938,7 @@ class GLTFParser {
|
|
1928
1938
|
materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);
|
1929
1939
|
}
|
1930
1940
|
if (materialDef.emissiveTexture !== void 0 && materialType !== MeshBasicMaterial) {
|
1931
|
-
pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture,
|
1941
|
+
pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture, 3001));
|
1932
1942
|
}
|
1933
1943
|
return Promise.all(pending).then(function() {
|
1934
1944
|
const material = new materialType(materialParams);
|