three-stdlib 2.7.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- package/{Nodes-ec4e1143.js → Nodes-894ac9dc.js} +0 -0
- package/{Nodes-427f68b0.js → Nodes-af575af7.js} +0 -0
- package/cameras/CinematicCamera.cjs.js +1 -1
- package/cameras/CinematicCamera.js +3 -8
- package/controls/ArcballControls.cjs.js +1 -1
- package/controls/ArcballControls.d.ts +6 -9
- package/controls/ArcballControls.js +188 -234
- package/controls/FirstPersonControls.cjs.js +1 -1
- package/controls/FirstPersonControls.d.ts +4 -5
- package/controls/FirstPersonControls.js +36 -45
- package/controls/TransformControls.cjs.js +1 -1
- package/controls/TransformControls.d.ts +2 -1
- package/controls/TransformControls.js +25 -26
- package/exporters/GLTFExporter.cjs.js +1 -1
- package/exporters/GLTFExporter.js +9 -18
- package/geometries/TeapotGeometry.js +2 -2
- package/index.cjs.js +1 -1
- package/loaders/EXRLoader.cjs.js +1 -1
- package/loaders/EXRLoader.js +21 -10
- package/loaders/GLTFLoader.cjs.js +1 -1
- package/loaders/GLTFLoader.js +5 -6
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
- package/loaders/HDRCubeTextureLoader.js +1 -3
- package/loaders/LDrawLoader.cjs.js +1 -1
- package/loaders/LDrawLoader.js +1450 -1105
- package/loaders/LUT3dlLoader.cjs.js +1 -1
- package/loaders/LUT3dlLoader.js +18 -11
- package/loaders/LUTCubeLoader.cjs.js +1 -1
- package/loaders/LUTCubeLoader.js +4 -5
- package/loaders/NodeMaterialLoader.cjs.js +1 -1
- package/loaders/PCDLoader.cjs.js +1 -1
- package/loaders/PCDLoader.js +2 -2
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +6 -6
- package/loaders/STLLoader.js +7 -7
- package/loaders/VRMLLoader.cjs.js +1 -1
- package/loaders/VRMLLoader.js +10 -18
- package/modifiers/CurveModifier.cjs.js +1 -1
- package/modifiers/CurveModifier.js +9 -8
- package/nodes/accessors/CameraNode.js +12 -12
- package/nodes/accessors/PositionNode.js +3 -3
- package/nodes/accessors/ReflectNode.js +3 -3
- package/nodes/core/FunctionNode.js +3 -3
- package/nodes/core/InputNode.js +3 -3
- package/nodes/core/Node.js +6 -6
- package/nodes/core/TempNode.js +6 -6
- package/nodes/effects/BlurNode.js +3 -3
- package/nodes/math/MathNode.js +3 -3
- package/nodes/utils/VelocityNode.js +6 -6
- package/objects/Lensflare.cjs.js +1 -1
- package/objects/Lensflare.js +3 -11
- package/objects/Reflector.cjs.js +1 -1
- package/objects/Reflector.js +16 -12
- package/objects/ReflectorForSSRPass.cjs.js +1 -1
- package/objects/ReflectorForSSRPass.js +1 -9
- package/objects/Refractor.cjs.js +1 -1
- package/objects/Refractor.js +7 -12
- package/objects/Water.cjs.js +1 -1
- package/objects/Water.js +5 -16
- package/package.json +2 -2
- package/postprocessing/GlitchPass.cjs.js +1 -1
- package/postprocessing/GlitchPass.js +36 -33
- package/postprocessing/SMAAPass.cjs.js +1 -1
- package/postprocessing/SMAAPass.js +93 -96
- package/postprocessing/SSAOPass.cjs.js +1 -1
- package/postprocessing/SSAOPass.js +151 -152
- package/postprocessing/SavePass.cjs.js +1 -1
- package/postprocessing/SavePass.js +27 -28
- package/renderers/nodes/accessors/UVNode.js +1 -3
- package/renderers/nodes/core/AttributeNode.js +1 -3
- package/renderers/nodes/core/Node.js +4 -12
- package/renderers/nodes/core/NodeBuilder.js +6 -18
- package/renderers/webgpu/WebGPUTextures.cjs.js +1 -1
- package/renderers/webgpu/WebGPUTextures.js +1 -2
- package/utils/LDrawUtils.cjs.js +1 -0
- package/utils/LDrawUtils.js +144 -0
- package/webxr/ARButton.js +6 -6
- package/webxr/VRButton.js +6 -6
@@ -0,0 +1,144 @@
|
|
1
|
+
import { Matrix3, Group, Mesh, LineSegments, BufferGeometry, BufferAttribute } from 'three';
|
2
|
+
import { m as mergeBufferGeometries } from '../BufferGeometryUtils-582025b8.js';
|
3
|
+
import '../types/helpers.js';
|
4
|
+
|
5
|
+
class LDrawUtils {
|
6
|
+
static mergeObject(object) {
|
7
|
+
// Merges geometries in object by materials and returns new object. Use on not indexed geometries.
|
8
|
+
// The object buffers reference the old object ones.
|
9
|
+
// Special treatment is done to the conditional lines generated by LDrawLoader.
|
10
|
+
function extractGroup(geometry, group, elementSize, isConditionalLine) {
|
11
|
+
// Extracts a group from a geometry as a new geometry (with attribute buffers referencing original buffers)
|
12
|
+
const newGeometry = new BufferGeometry();
|
13
|
+
const originalPositions = geometry.getAttribute('position').array;
|
14
|
+
const originalNormals = elementSize === 3 ? geometry.getAttribute('normal').array : null;
|
15
|
+
const numVertsGroup = Math.min(group.count, Math.floor(originalPositions.length / 3) - group.start);
|
16
|
+
const vertStart = group.start * 3;
|
17
|
+
const vertEnd = (group.start + numVertsGroup) * 3;
|
18
|
+
const positions = originalPositions.subarray(vertStart, vertEnd);
|
19
|
+
const normals = originalNormals !== null ? originalNormals.subarray(vertStart, vertEnd) : null;
|
20
|
+
newGeometry.setAttribute('position', new BufferAttribute(positions, 3));
|
21
|
+
if (normals !== null) newGeometry.setAttribute('normal', new BufferAttribute(normals, 3));
|
22
|
+
|
23
|
+
if (isConditionalLine) {
|
24
|
+
const controlArray0 = geometry.getAttribute('control0').array.subarray(vertStart, vertEnd);
|
25
|
+
const controlArray1 = geometry.getAttribute('control1').array.subarray(vertStart, vertEnd);
|
26
|
+
const directionArray = geometry.getAttribute('direction').array.subarray(vertStart, vertEnd);
|
27
|
+
newGeometry.setAttribute('control0', new BufferAttribute(controlArray0, 3, false));
|
28
|
+
newGeometry.setAttribute('control1', new BufferAttribute(controlArray1, 3, false));
|
29
|
+
newGeometry.setAttribute('direction', new BufferAttribute(directionArray, 3, false));
|
30
|
+
}
|
31
|
+
|
32
|
+
return newGeometry;
|
33
|
+
}
|
34
|
+
|
35
|
+
function addGeometry(mat, geometry, geometries) {
|
36
|
+
const geoms = geometries[mat.uuid];
|
37
|
+
|
38
|
+
if (!geoms) {
|
39
|
+
geometries[mat.uuid] = {
|
40
|
+
mat: mat,
|
41
|
+
arr: [geometry]
|
42
|
+
};
|
43
|
+
} else {
|
44
|
+
geoms.arr.push(geometry);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
function permuteAttribute(attribute, elemSize) {
|
49
|
+
// Permutes first two vertices of each attribute element
|
50
|
+
if (!attribute) return;
|
51
|
+
const verts = attribute.array;
|
52
|
+
const numVerts = Math.floor(verts.length / 3);
|
53
|
+
let offset = 0;
|
54
|
+
|
55
|
+
for (let i = 0; i < numVerts; i++) {
|
56
|
+
const x = verts[offset];
|
57
|
+
const y = verts[offset + 1];
|
58
|
+
const z = verts[offset + 2];
|
59
|
+
verts[offset] = verts[offset + 3];
|
60
|
+
verts[offset + 1] = verts[offset + 4];
|
61
|
+
verts[offset + 2] = verts[offset + 5];
|
62
|
+
verts[offset + 3] = x;
|
63
|
+
verts[offset + 4] = y;
|
64
|
+
verts[offset + 5] = z;
|
65
|
+
offset += elemSize * 3;
|
66
|
+
}
|
67
|
+
} // Traverse the object hierarchy collecting geometries and transforming them to world space
|
68
|
+
|
69
|
+
|
70
|
+
const meshGeometries = {};
|
71
|
+
const linesGeometries = {};
|
72
|
+
const condLinesGeometries = {};
|
73
|
+
object.updateMatrixWorld(true);
|
74
|
+
const normalMatrix = new Matrix3();
|
75
|
+
object.traverse(c => {
|
76
|
+
if (c.isMesh | c.isLineSegments) {
|
77
|
+
const elemSize = c.isMesh ? 3 : 2;
|
78
|
+
const geometry = c.geometry.clone();
|
79
|
+
const matrixIsInverted = c.matrixWorld.determinant() < 0;
|
80
|
+
|
81
|
+
if (matrixIsInverted) {
|
82
|
+
permuteAttribute(geometry.attributes.position, elemSize);
|
83
|
+
permuteAttribute(geometry.attributes.normal, elemSize);
|
84
|
+
}
|
85
|
+
|
86
|
+
geometry.applyMatrix4(c.matrixWorld);
|
87
|
+
|
88
|
+
if (c.isConditionalLine) {
|
89
|
+
geometry.attributes.control0.applyMatrix4(c.matrixWorld);
|
90
|
+
geometry.attributes.control1.applyMatrix4(c.matrixWorld);
|
91
|
+
normalMatrix.getNormalMatrix(c.matrixWorld);
|
92
|
+
geometry.attributes.direction.applyNormalMatrix(normalMatrix);
|
93
|
+
}
|
94
|
+
|
95
|
+
const geometries = c.isMesh ? meshGeometries : c.isConditionalLine ? condLinesGeometries : linesGeometries;
|
96
|
+
|
97
|
+
if (Array.isArray(c.material)) {
|
98
|
+
for (const groupIndex in geometry.groups) {
|
99
|
+
const group = geometry.groups[groupIndex];
|
100
|
+
const mat = c.material[group.materialIndex];
|
101
|
+
const newGeometry = extractGroup(geometry, group, elemSize, c.isConditionalLine);
|
102
|
+
addGeometry(mat, newGeometry, geometries);
|
103
|
+
}
|
104
|
+
} else {
|
105
|
+
addGeometry(c.material, geometry, geometries);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}); // Create object with merged geometries
|
109
|
+
|
110
|
+
const mergedObject = new Group();
|
111
|
+
const meshMaterialsIds = Object.keys(meshGeometries);
|
112
|
+
|
113
|
+
for (const i in meshMaterialsIds) {
|
114
|
+
const meshGeometry = meshGeometries[meshMaterialsIds[i]];
|
115
|
+
const mergedGeometry = mergeBufferGeometries(meshGeometry.arr);
|
116
|
+
mergedObject.add(new Mesh(mergedGeometry, meshGeometry.mat));
|
117
|
+
}
|
118
|
+
|
119
|
+
const linesMaterialsIds = Object.keys(linesGeometries);
|
120
|
+
|
121
|
+
for (const i in linesMaterialsIds) {
|
122
|
+
const lineGeometry = linesGeometries[linesMaterialsIds[i]];
|
123
|
+
const mergedGeometry = mergeBufferGeometries(lineGeometry.arr);
|
124
|
+
mergedObject.add(new LineSegments(mergedGeometry, lineGeometry.mat));
|
125
|
+
}
|
126
|
+
|
127
|
+
const condLinesMaterialsIds = Object.keys(condLinesGeometries);
|
128
|
+
|
129
|
+
for (const i in condLinesMaterialsIds) {
|
130
|
+
const condLineGeometry = condLinesGeometries[condLinesMaterialsIds[i]];
|
131
|
+
const mergedGeometry = mergeBufferGeometries(condLineGeometry.arr);
|
132
|
+
const condLines = new LineSegments(mergedGeometry, condLineGeometry.mat);
|
133
|
+
condLines.isConditionalLine = true;
|
134
|
+
mergedObject.add(condLines);
|
135
|
+
}
|
136
|
+
|
137
|
+
mergedObject.userData.constructionStep = 0;
|
138
|
+
mergedObject.userData.numConstructionSteps = 1;
|
139
|
+
return mergedObject;
|
140
|
+
}
|
141
|
+
|
142
|
+
}
|
143
|
+
|
144
|
+
export { LDrawUtils };
|
package/webxr/ARButton.js
CHANGED
@@ -2,9 +2,9 @@ class ARButton {
|
|
2
2
|
static createButton(renderer, sessionInit = {}) {
|
3
3
|
const button = document.createElement('button');
|
4
4
|
|
5
|
-
function
|
6
|
-
|
7
|
-
{
|
5
|
+
function
|
6
|
+
/*device*/
|
7
|
+
showStartAR() {
|
8
8
|
if (sessionInit.domOverlay === undefined) {
|
9
9
|
var overlay = document.createElement('div');
|
10
10
|
overlay.style.display = 'none';
|
@@ -47,9 +47,9 @@ class ARButton {
|
|
47
47
|
currentSession = session;
|
48
48
|
}
|
49
49
|
|
50
|
-
function
|
51
|
-
|
52
|
-
{
|
50
|
+
function
|
51
|
+
/*event*/
|
52
|
+
onSessionEnded() {
|
53
53
|
currentSession.removeEventListener('end', onSessionEnded);
|
54
54
|
button.textContent = 'START AR';
|
55
55
|
sessionInit.domOverlay.root.style.display = 'none';
|
package/webxr/VRButton.js
CHANGED
@@ -6,9 +6,9 @@ class VRButton {
|
|
6
6
|
|
7
7
|
const button = document.createElement('button');
|
8
8
|
|
9
|
-
function
|
10
|
-
|
11
|
-
{
|
9
|
+
function
|
10
|
+
/*device*/
|
11
|
+
showEnterVR() {
|
12
12
|
let currentSession = null;
|
13
13
|
|
14
14
|
async function onSessionStarted(session) {
|
@@ -18,9 +18,9 @@ class VRButton {
|
|
18
18
|
currentSession = session;
|
19
19
|
}
|
20
20
|
|
21
|
-
function
|
22
|
-
|
23
|
-
{
|
21
|
+
function
|
22
|
+
/*event*/
|
23
|
+
onSessionEnded() {
|
24
24
|
currentSession.removeEventListener('end', onSessionEnded);
|
25
25
|
button.textContent = 'ENTER VR';
|
26
26
|
currentSession = null;
|