@needle-tools/three 0.146.1 → 0.146.2
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;
|