@threlte/gltf 1.0.0-next.2 → 1.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/cli.js +5 -4
- package/package.json +3 -2
- package/readme.md +7 -4
- package/src/index.js +8 -9
- package/src/utils/parser.js +31 -16
- package/src/bin/DRACOLoader.js +0 -208
- package/src/bin/GLTFLoader.js +0 -2734
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @threlte/gltf
|
|
2
2
|
|
|
3
|
+
## 1.0.0-next.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 16e75c31: Fixed a bug where the suspense was created in the wrong place when preloading was activated.
|
|
8
|
+
|
|
9
|
+
## 1.0.0-next.3
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- a07850e4: Removed the name from the exported preload function (seems silly and might collide anyway), updated deps and included three-stdlib instead of rolling an own implementation of GLTFLoader and DRACOLoader. Added option to make the component suspense-ready, updated README.
|
|
14
|
+
|
|
3
15
|
## 1.0.0-next.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/cli.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
3
|
import meow from 'meow'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
4
|
import { dirname } from 'path'
|
|
7
|
-
import gltf from './src/index.js'
|
|
8
5
|
import { readPackageUpSync } from 'read-pkg-up'
|
|
6
|
+
import { fileURLToPath } from 'url'
|
|
7
|
+
import gltf from './src/index.js'
|
|
9
8
|
|
|
10
9
|
const __filename = fileURLToPath(import.meta.url)
|
|
11
10
|
const __dirname = dirname(__filename)
|
|
@@ -26,6 +25,7 @@ const cli = meow(
|
|
|
26
25
|
--precision, -p Number of fractional digits (default: 2)
|
|
27
26
|
--draco, -d Draco binary path
|
|
28
27
|
--preload -P Add preload method to module script
|
|
28
|
+
--suspense -u Make the component suspense-ready
|
|
29
29
|
--isolated, -i Output as isolated module (No $$restProps usage)
|
|
30
30
|
--root, -r Sets directory from which .gltf file is served
|
|
31
31
|
--transform, -T Transform the asset for the web (draco, prune, resize)
|
|
@@ -49,6 +49,7 @@ const cli = meow(
|
|
|
49
49
|
precision: { type: 'number', alias: 'p', default: 2 },
|
|
50
50
|
isolated: { type: 'boolean', alias: 'i', default: false },
|
|
51
51
|
preload: { type: 'boolean', alias: 'P', default: false },
|
|
52
|
+
suspense: { type: 'boolean', alias: 'u', default: false },
|
|
52
53
|
draco: { type: 'string', alias: 'd' },
|
|
53
54
|
root: { type: 'string', alias: 'r' },
|
|
54
55
|
transform: { type: 'boolean', alias: 'T' },
|
|
@@ -90,7 +91,7 @@ Command: npx @threlte/gltf@${packageJson.version} ${process.argv.slice(2).join('
|
|
|
90
91
|
console.info('log:', log)
|
|
91
92
|
}
|
|
92
93
|
try {
|
|
93
|
-
const response = await gltf(file, output,
|
|
94
|
+
const response = await gltf(file, output, {
|
|
94
95
|
...config,
|
|
95
96
|
showLog,
|
|
96
97
|
timeout: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/gltf",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.4",
|
|
4
4
|
"description": "GLTF to Threlte converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"prettier-plugin-svelte": "^2.9.0",
|
|
44
44
|
"sharp": "^0.31.3",
|
|
45
45
|
"svelte": "^3.55.1",
|
|
46
|
-
"three": "0.
|
|
46
|
+
"three": "0.151.3",
|
|
47
|
+
"three-stdlib": "^2.21.8"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"chalk": "^4.1.1",
|
package/readme.md
CHANGED
|
@@ -27,16 +27,19 @@ Options
|
|
|
27
27
|
--keepnames, -k Keep original names
|
|
28
28
|
--keepgroups, -K Keep (empty) groups, disable pruning
|
|
29
29
|
--meta, -m Include metadata (as userData)
|
|
30
|
-
--shadows, s
|
|
31
|
-
--printwidth, w
|
|
30
|
+
--shadows, -s Let meshes cast and receive shadows
|
|
31
|
+
--printwidth, -w Prettier printWidth (default: 120)
|
|
32
32
|
--precision, -p Number of fractional digits (default: 2)
|
|
33
33
|
--draco, -d Draco binary path
|
|
34
|
+
--preload -P Add preload method to module script
|
|
35
|
+
--suspense -u Make the component suspense-ready
|
|
36
|
+
--isolated, -i Output as isolated module (No $$restProps usage)
|
|
34
37
|
--root, -r Sets directory from which .gltf file is served
|
|
35
38
|
--transform, -T Transform the asset for the web (draco, prune, resize)
|
|
36
39
|
--resolution, -R Transform resolution for texture resizing (default: 1024)
|
|
37
40
|
--simplify, -S Transform simplification (default: false) (experimental!)
|
|
38
41
|
--weld Weld tolerance (default: 0.0001)
|
|
39
|
-
--ratio Simplifier ratio (default: 0.
|
|
42
|
+
--ratio Simplifier ratio (default: 0.75)
|
|
40
43
|
--error Simplifier error threshold (default: 0.001)
|
|
41
44
|
--debug, -D Debug output
|
|
42
45
|
```
|
|
@@ -217,7 +220,7 @@ If you want to play an animation you can do so at any time:
|
|
|
217
220
|
|
|
218
221
|
```ts
|
|
219
222
|
const onEvent = () => {
|
|
220
|
-
|
|
223
|
+
$actions.jump.play()
|
|
221
224
|
}
|
|
222
225
|
```
|
|
223
226
|
|
package/src/index.js
CHANGED
|
@@ -2,18 +2,17 @@ import 'jsdom-global'
|
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import transform from './utils/transform.js'
|
|
5
|
-
|
|
5
|
+
import { GLTFLoader, DRACOLoader } from 'three-stdlib'
|
|
6
6
|
import * as prettier from 'prettier'
|
|
7
|
-
import THREE from 'three'
|
|
7
|
+
import * as THREE from 'three'
|
|
8
8
|
global.THREE = THREE
|
|
9
9
|
|
|
10
|
-
import './bin/GLTFLoader.js'
|
|
11
|
-
import DracoLoader from './bin/DRACOLoader.js'
|
|
12
|
-
THREE.DRACOLoader.getDecoderModule = () => {}
|
|
13
10
|
import parse from './utils/parser.js'
|
|
14
11
|
|
|
15
|
-
const gltfLoader = new
|
|
16
|
-
|
|
12
|
+
const gltfLoader = new GLTFLoader()
|
|
13
|
+
const dracoloader = new DRACOLoader()
|
|
14
|
+
dracoloader.setDecoderPath('https://www.gstatic.com/draco/v1/decoders/')
|
|
15
|
+
gltfLoader.setDRACOLoader(dracoloader)
|
|
17
16
|
|
|
18
17
|
function toArrayBuffer(buf) {
|
|
19
18
|
var ab = new ArrayBuffer(buf.length)
|
|
@@ -22,7 +21,7 @@ function toArrayBuffer(buf) {
|
|
|
22
21
|
return ab
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
export default function (file, output,
|
|
24
|
+
export default function (file, output, options) {
|
|
26
25
|
function getRelativeFilePath(file) {
|
|
27
26
|
const filePath = path.resolve(file)
|
|
28
27
|
const rootPath = options.root ? path.resolve(options.root) : path.dirname(file)
|
|
@@ -53,7 +52,7 @@ export default function (file, output, baseName, options) {
|
|
|
53
52
|
arrayBuffer,
|
|
54
53
|
'',
|
|
55
54
|
(gltf) => {
|
|
56
|
-
const raw = parse(filePath,
|
|
55
|
+
const raw = parse(filePath, gltf, options)
|
|
57
56
|
try {
|
|
58
57
|
const prettiered = prettier.format(raw, {
|
|
59
58
|
semi: false,
|
package/src/utils/parser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import THREE from 'three'
|
|
1
|
+
import * as THREE from 'three'
|
|
2
2
|
import isVarName from './isVarName.js'
|
|
3
3
|
|
|
4
|
-
function parse(fileName,
|
|
4
|
+
function parse(fileName, gltf, options = {}) {
|
|
5
5
|
const url = (fileName.toLowerCase().startsWith('http') ? '' : '/') + fileName
|
|
6
6
|
const animations = gltf.animations
|
|
7
7
|
const hasAnimations = animations.length > 0
|
|
@@ -183,7 +183,11 @@ function parse(fileName, baseName, gltf, options = {}) {
|
|
|
183
183
|
result += `position={[${rNbr(obj.position.x)}, ${rNbr(obj.position.y)}, ${rNbr(
|
|
184
184
|
obj.position.z
|
|
185
185
|
)},]} `
|
|
186
|
-
if (
|
|
186
|
+
if (
|
|
187
|
+
obj.rotation &&
|
|
188
|
+
obj.rotation.isEuler &&
|
|
189
|
+
rNbr(new THREE.Vector3(...obj.rotation.toArray()).length())
|
|
190
|
+
)
|
|
187
191
|
result += `rotation={[${rDeg(obj.rotation.x)}, ${rDeg(obj.rotation.y)}, ${rDeg(
|
|
188
192
|
obj.rotation.z
|
|
189
193
|
)},]} `
|
|
@@ -473,15 +477,23 @@ function parse(fileName, baseName, gltf, options = {}) {
|
|
|
473
477
|
import { ${[
|
|
474
478
|
'T',
|
|
475
479
|
options.types && !options.isolated ? 'type Props, type Events, type Slots' : ''
|
|
476
|
-
]
|
|
477
|
-
|
|
478
|
-
', '
|
|
479
|
-
|
|
480
|
+
]
|
|
481
|
+
.filter(Boolean)
|
|
482
|
+
.join(', ')} } from '@threlte/core'
|
|
483
|
+
import { ${[
|
|
484
|
+
'useGltf',
|
|
485
|
+
hasAnimations ? 'useGltfAnimations' : '',
|
|
486
|
+
options.suspense ? 'useSuspense' : ''
|
|
487
|
+
]
|
|
488
|
+
.filter(Boolean)
|
|
489
|
+
.join(', ')} } from '@threlte/extras'
|
|
480
490
|
`
|
|
481
491
|
|
|
482
|
-
const useGltf =
|
|
483
|
-
|
|
484
|
-
})`
|
|
492
|
+
const useGltf = `${options.suspense ? 'suspend(' : ''}useGltf${
|
|
493
|
+
options.types ? '<GLTFResult>' : ''
|
|
494
|
+
}('${url}'${useGltfOptions ? `, ${JSON.stringify(useGltfOptions)}` : ''})${
|
|
495
|
+
options.suspense ? ')' : ''
|
|
496
|
+
}`
|
|
485
497
|
|
|
486
498
|
// Output
|
|
487
499
|
return `
|
|
@@ -503,10 +515,11 @@ ${
|
|
|
503
515
|
${options.types ? printThrelteTypes(objects, animations) : ''}
|
|
504
516
|
|
|
505
517
|
const load = () => {
|
|
518
|
+
${options.suspend ? 'const suspend = useSuspense()' : ''}
|
|
506
519
|
return ${useGltf}
|
|
507
520
|
}
|
|
508
521
|
|
|
509
|
-
export const preload
|
|
522
|
+
export const preload = async () => {
|
|
510
523
|
await load()
|
|
511
524
|
}
|
|
512
525
|
</script>
|
|
@@ -525,6 +538,8 @@ ${
|
|
|
525
538
|
|
|
526
539
|
export const ref = new Group()
|
|
527
540
|
|
|
541
|
+
${!options.preload && options.suspense ? 'const suspend = useSuspense()' : ''}
|
|
542
|
+
|
|
528
543
|
${options.types && !options.preload ? printThrelteTypes(objects, animations) : ''}
|
|
529
544
|
|
|
530
545
|
${!options.preload ? `const gltf = ${useGltf}` : 'const gltf = load()'}
|
|
@@ -538,13 +553,13 @@ ${
|
|
|
538
553
|
|
|
539
554
|
</script>
|
|
540
555
|
|
|
541
|
-
|
|
542
|
-
|
|
556
|
+
<T is={ref} dispose={false} ${!options.isolated ? '{...$$restProps}' : ''}>
|
|
557
|
+
{#if $gltf}
|
|
543
558
|
${scene}
|
|
559
|
+
{/if}
|
|
544
560
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
{/if}
|
|
561
|
+
<slot {ref} />
|
|
562
|
+
</T>
|
|
548
563
|
`
|
|
549
564
|
}
|
|
550
565
|
|
package/src/bin/DRACOLoader.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
import THREE from 'three'
|
|
3
|
-
import draco from 'draco3dgltf'
|
|
4
|
-
const decoder = draco.createDecoderModule()
|
|
5
|
-
const DRACOLoader = (THREE.DRACOLoader = function (t) {
|
|
6
|
-
;(this.timeLoaded = 0),
|
|
7
|
-
(this.manager = t || THREE.DefaultLoadingManager),
|
|
8
|
-
(this.materials = null),
|
|
9
|
-
(this.verbosity = 0),
|
|
10
|
-
(this.attributeOptions = {}),
|
|
11
|
-
(this.drawMode = THREE.TrianglesDrawMode),
|
|
12
|
-
(this.nativeAttributeMap = { position: 'POSITION', normal: 'NORMAL', color: 'COLOR', uv: 'TEX_COORD' })
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export default DRACOLoader
|
|
16
|
-
|
|
17
|
-
THREE.DRACOLoader.prototype = {
|
|
18
|
-
constructor: THREE.DRACOLoader,
|
|
19
|
-
load: function (t, e, r, o) {
|
|
20
|
-
var i = this,
|
|
21
|
-
n = new THREE.FileLoader(i.manager)
|
|
22
|
-
n.setPath(this.path),
|
|
23
|
-
n.setResponseType('arraybuffer'),
|
|
24
|
-
n.load(
|
|
25
|
-
t,
|
|
26
|
-
function (t) {
|
|
27
|
-
i.decodeDracoFile(t, e)
|
|
28
|
-
},
|
|
29
|
-
r,
|
|
30
|
-
o
|
|
31
|
-
)
|
|
32
|
-
},
|
|
33
|
-
setPath: function (t) {
|
|
34
|
-
return (this.path = t), this
|
|
35
|
-
},
|
|
36
|
-
setVerbosity: function (t) {
|
|
37
|
-
return (this.verbosity = t), this
|
|
38
|
-
},
|
|
39
|
-
setDrawMode: function (t) {
|
|
40
|
-
return (this.drawMode = t), this
|
|
41
|
-
},
|
|
42
|
-
setSkipDequantization: function (t, e) {
|
|
43
|
-
var r = !0
|
|
44
|
-
return void 0 !== e && (r = e), (this.getAttributeOptions(t).skipDequantization = r), this
|
|
45
|
-
},
|
|
46
|
-
decodeDracoFile: function (t, e, r, o) {
|
|
47
|
-
decoder.then((decoder) => this.decodeDracoFileInternal(t, decoder, e, r, o))
|
|
48
|
-
},
|
|
49
|
-
decodeDracoFileInternal: function (t, e, r, o, i) {
|
|
50
|
-
var n = new e.DecoderBuffer()
|
|
51
|
-
n.Init(new Int8Array(t), t.byteLength)
|
|
52
|
-
var a = new e.Decoder(),
|
|
53
|
-
s = a.GetEncodedGeometryType(n)
|
|
54
|
-
if (s == e.TRIANGULAR_MESH) this.verbosity > 0 && console.log('Loaded a mesh.')
|
|
55
|
-
else {
|
|
56
|
-
if (s != e.POINT_CLOUD) {
|
|
57
|
-
var u = 'THREE.DRACOLoader: Unknown geometry type.'
|
|
58
|
-
//throw (console.error(u), new Error(u))
|
|
59
|
-
}
|
|
60
|
-
this.verbosity > 0 && console.log('Loaded a point cloud.')
|
|
61
|
-
}
|
|
62
|
-
r(this.convertDracoGeometryTo3JS(e, a, s, n, o, i))
|
|
63
|
-
},
|
|
64
|
-
addAttributeToGeometry: function (t, e, r, o, i, n, a, s) {
|
|
65
|
-
if (0 === n.ptr) {
|
|
66
|
-
var u = 'THREE.DRACOLoader: No attribute ' + o
|
|
67
|
-
throw (console.error(u), new Error(u))
|
|
68
|
-
}
|
|
69
|
-
var d,
|
|
70
|
-
A,
|
|
71
|
-
c = n.num_components(),
|
|
72
|
-
l = r.num_points() * c
|
|
73
|
-
switch (i) {
|
|
74
|
-
case Float32Array:
|
|
75
|
-
;(d = new t.DracoFloat32Array()),
|
|
76
|
-
e.GetAttributeFloatForAllPoints(r, n, d),
|
|
77
|
-
(s[o] = new Float32Array(l)),
|
|
78
|
-
(A = THREE.Float32BufferAttribute)
|
|
79
|
-
break
|
|
80
|
-
case Int8Array:
|
|
81
|
-
;(d = new t.DracoInt8Array()),
|
|
82
|
-
e.GetAttributeInt8ForAllPoints(r, n, d),
|
|
83
|
-
(s[o] = new Int8Array(l)),
|
|
84
|
-
(A = THREE.Int8BufferAttribute)
|
|
85
|
-
break
|
|
86
|
-
case Int16Array:
|
|
87
|
-
;(d = new t.DracoInt16Array()),
|
|
88
|
-
e.GetAttributeInt16ForAllPoints(r, n, d),
|
|
89
|
-
(s[o] = new Int16Array(l)),
|
|
90
|
-
(A = THREE.Int16BufferAttribute)
|
|
91
|
-
break
|
|
92
|
-
case Int32Array:
|
|
93
|
-
;(d = new t.DracoInt32Array()),
|
|
94
|
-
e.GetAttributeInt32ForAllPoints(r, n, d),
|
|
95
|
-
(s[o] = new Int32Array(l)),
|
|
96
|
-
(A = THREE.Int32BufferAttribute)
|
|
97
|
-
break
|
|
98
|
-
case Uint8Array:
|
|
99
|
-
;(d = new t.DracoUInt8Array()),
|
|
100
|
-
e.GetAttributeUInt8ForAllPoints(r, n, d),
|
|
101
|
-
(s[o] = new Uint8Array(l)),
|
|
102
|
-
(A = THREE.Uint8BufferAttribute)
|
|
103
|
-
break
|
|
104
|
-
case Uint16Array:
|
|
105
|
-
;(d = new t.DracoUInt16Array()),
|
|
106
|
-
e.GetAttributeUInt16ForAllPoints(r, n, d),
|
|
107
|
-
(s[o] = new Uint16Array(l)),
|
|
108
|
-
(A = THREE.Uint16BufferAttribute)
|
|
109
|
-
break
|
|
110
|
-
case Uint32Array:
|
|
111
|
-
;(d = new t.DracoUInt32Array()),
|
|
112
|
-
e.GetAttributeUInt32ForAllPoints(r, n, d),
|
|
113
|
-
(s[o] = new Uint32Array(l)),
|
|
114
|
-
(A = THREE.Uint32BufferAttribute)
|
|
115
|
-
break
|
|
116
|
-
default:
|
|
117
|
-
u = 'THREE.DRACOLoader: Unexpected attribute type.'
|
|
118
|
-
throw (console.error(u), new Error(u))
|
|
119
|
-
}
|
|
120
|
-
for (var b = 0; b < l; b++) s[o][b] = d.GetValue(b)
|
|
121
|
-
a.setAttribute(o, new A(s[o], c)), t.destroy(d)
|
|
122
|
-
},
|
|
123
|
-
convertDracoGeometryTo3JS: function (t, e, r, o, i, n) {
|
|
124
|
-
var a, s, u
|
|
125
|
-
if (
|
|
126
|
-
(!0 === this.getAttributeOptions('position').skipDequantization && e.SkipAttributeTransform(t.POSITION),
|
|
127
|
-
r === t.TRIANGULAR_MESH
|
|
128
|
-
? ((a = new t.Mesh()), (s = e.DecodeBufferToMesh(o, a)))
|
|
129
|
-
: ((a = new t.PointCloud()), (s = e.DecodeBufferToPointCloud(o, a))),
|
|
130
|
-
!s.ok() || 0 == a.ptr)
|
|
131
|
-
) {
|
|
132
|
-
return new THREE.BufferGeometry()
|
|
133
|
-
var d = 'THREE.DRACOLoader: Decoding failed: '
|
|
134
|
-
throw ((d += s.error_msg()), console.error(d), t.destroy(e), t.destroy(a), new Error(d))
|
|
135
|
-
}
|
|
136
|
-
t.destroy(o),
|
|
137
|
-
r == t.TRIANGULAR_MESH
|
|
138
|
-
? ((u = a.num_faces()), this.verbosity > 0 && console.log('Number of faces loaded: ' + u.toString()))
|
|
139
|
-
: (u = 0)
|
|
140
|
-
var A = a.num_points(),
|
|
141
|
-
c = a.num_attributes()
|
|
142
|
-
this.verbosity > 0 &&
|
|
143
|
-
(console.log('Number of points loaded: ' + A.toString()),
|
|
144
|
-
console.log('Number of attributes loaded: ' + c.toString()))
|
|
145
|
-
var l = e.GetAttributeId(a, t.POSITION)
|
|
146
|
-
if (-1 == l) {
|
|
147
|
-
d = 'THREE.DRACOLoader: No position attribute found.'
|
|
148
|
-
throw (console.error(d), t.destroy(e), t.destroy(a), new Error(d))
|
|
149
|
-
}
|
|
150
|
-
var b = e.GetAttribute(a, l),
|
|
151
|
-
f = {},
|
|
152
|
-
y = new THREE.BufferGeometry()
|
|
153
|
-
if (i)
|
|
154
|
-
for (var E in i) {
|
|
155
|
-
var h = n[E],
|
|
156
|
-
w = i[E],
|
|
157
|
-
p = e.GetAttributeByUniqueId(a, w)
|
|
158
|
-
//this.addAttributeToGeometry(t, e, a, E, h, p, y, f)
|
|
159
|
-
}
|
|
160
|
-
else
|
|
161
|
-
for (var E in this.nativeAttributeMap) {
|
|
162
|
-
var T = e.GetAttributeId(a, t[this.nativeAttributeMap[E]])
|
|
163
|
-
if (-1 !== T) {
|
|
164
|
-
this.verbosity > 0 && console.log('Loaded ' + E + ' attribute.')
|
|
165
|
-
p = e.GetAttribute(a, T)
|
|
166
|
-
//this.addAttributeToGeometry(t, e, a, E, Float32Array, p, y, f)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (r == t.TRIANGULAR_MESH)
|
|
170
|
-
if (this.drawMode === THREE.TriangleStripDrawMode) {
|
|
171
|
-
var R = new t.DracoInt32Array()
|
|
172
|
-
e.GetTriangleStripsFromMesh(a, R)
|
|
173
|
-
f.indices = new Uint32Array(R.size())
|
|
174
|
-
for (var I = 0; I < R.size(); ++I) f.indices[I] = R.GetValue(I)
|
|
175
|
-
t.destroy(R)
|
|
176
|
-
} else {
|
|
177
|
-
var v = 3 * u
|
|
178
|
-
f.indices = new Uint32Array(v)
|
|
179
|
-
var D = new t.DracoInt32Array()
|
|
180
|
-
for (I = 0; I < u; ++I) {
|
|
181
|
-
e.GetFaceFromMesh(a, I, D)
|
|
182
|
-
var m = 3 * I
|
|
183
|
-
;(f.indices[m] = D.GetValue(0)), (f.indices[m + 1] = D.GetValue(1)), (f.indices[m + 2] = D.GetValue(2))
|
|
184
|
-
}
|
|
185
|
-
t.destroy(D)
|
|
186
|
-
}
|
|
187
|
-
;(y.drawMode = this.drawMode),
|
|
188
|
-
r == t.TRIANGULAR_MESH &&
|
|
189
|
-
y.setIndex(
|
|
190
|
-
new (f.indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute)(f.indices, 1)
|
|
191
|
-
)
|
|
192
|
-
var G = new t.AttributeQuantizationTransform()
|
|
193
|
-
if (G.InitFromAttribute(b)) {
|
|
194
|
-
;(y.attributes.position.isQuantized = !0),
|
|
195
|
-
(y.attributes.position.maxRange = G.range()),
|
|
196
|
-
(y.attributes.position.numQuantizationBits = G.quantization_bits()),
|
|
197
|
-
(y.attributes.position.minValues = new Float32Array(3))
|
|
198
|
-
for (I = 0; I < 3; ++I) y.attributes.position.minValues[I] = G.min_value(I)
|
|
199
|
-
}
|
|
200
|
-
return t.destroy(G), t.destroy(e), t.destroy(a), y
|
|
201
|
-
},
|
|
202
|
-
isVersionSupported: function (t, e) {
|
|
203
|
-
e(decoder.isVersionSupported(t))
|
|
204
|
-
},
|
|
205
|
-
getAttributeOptions: function (t) {
|
|
206
|
-
return void 0 === this.attributeOptions[t] && (this.attributeOptions[t] = {}), this.attributeOptions[t]
|
|
207
|
-
},
|
|
208
|
-
}
|