@needle-tools/three 0.146.1 → 0.146.3
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.
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
} from 'three';
|
|
16
16
|
import * as fflate from '../libs/fflate.module.js';
|
|
17
17
|
|
|
18
|
+
function makeNameSafe(str){
|
|
19
|
+
return str.replace(/[^a-zA-Z0-9_]/g, '');
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
class USDZDocument {
|
|
19
23
|
|
|
20
24
|
get isDocumentRoot() {
|
|
@@ -110,7 +114,7 @@ class USDZDocument {
|
|
|
110
114
|
customLayerData = {
|
|
111
115
|
string creator = "Three.js USDZExporter"
|
|
112
116
|
}
|
|
113
|
-
defaultPrim = "${this.name}"
|
|
117
|
+
defaultPrim = "${makeNameSafe(this.name)}"
|
|
114
118
|
metersPerUnit = 1
|
|
115
119
|
upAxis = "Y"
|
|
116
120
|
startTimeCode = 0
|
|
@@ -143,7 +147,7 @@ export class USDZObject {
|
|
|
143
147
|
constructor( id, name, matrix, mesh, material, camera ) {
|
|
144
148
|
|
|
145
149
|
this.uuid = id;
|
|
146
|
-
this.name = name;
|
|
150
|
+
this.name = makeNameSafe(name);
|
|
147
151
|
this.matrix = matrix;
|
|
148
152
|
this.geometry = mesh;
|
|
149
153
|
this.material = material;
|
|
@@ -340,6 +344,10 @@ class USDZExporterContext {
|
|
|
340
344
|
|
|
341
345
|
class USDZExporter {
|
|
342
346
|
|
|
347
|
+
constructor(){
|
|
348
|
+
this.debug = false;
|
|
349
|
+
}
|
|
350
|
+
|
|
343
351
|
async parse( scene, extensions, sceneAnchoringOptions = { ar: { anchoring: { type: 'plane' }, planeAnchoring: { alignment: 'horizontal' } } } ) {
|
|
344
352
|
|
|
345
353
|
this.sceneAnchoringOptions = sceneAnchoringOptions;
|
|
@@ -376,7 +384,8 @@ class USDZExporter {
|
|
|
376
384
|
this.lastUsda = final;
|
|
377
385
|
|
|
378
386
|
// full output file
|
|
379
|
-
|
|
387
|
+
if(this.debug)
|
|
388
|
+
console.log( final );
|
|
380
389
|
|
|
381
390
|
files[ modelFileName ] = fflate.strToU8( final );
|
|
382
391
|
context.output = null;
|
|
@@ -4248,8 +4248,9 @@ class GLTFParser {
|
|
|
4248
4248
|
const pendingOutputAccessors = [];
|
|
4249
4249
|
const pendingSamplers = [];
|
|
4250
4250
|
const pendingTargets = [];
|
|
4251
|
-
|
|
4252
|
-
|
|
4251
|
+
let i = 0;
|
|
4252
|
+
let il = animationDef.channels.length;
|
|
4253
|
+
for ( i = 0, il = animationDef.channels.length; i < il; i ++ ) {
|
|
4253
4254
|
|
|
4254
4255
|
const channel = animationDef.channels[ i ];
|
|
4255
4256
|
const sampler = animationDef.samplers[ channel.sampler ];
|
|
@@ -4289,7 +4290,7 @@ class GLTFParser {
|
|
|
4289
4290
|
|
|
4290
4291
|
const tracks = [];
|
|
4291
4292
|
|
|
4292
|
-
for (
|
|
4293
|
+
for ( i = 0, il = nodes.length; i < il; i ++ ) {
|
|
4293
4294
|
|
|
4294
4295
|
const node = nodes[ i ];
|
|
4295
4296
|
const inputAccessor = inputAccessors[ i ];
|