1
1
// src/modules/constants.js
2
- var KLEEVERSION = "0.8.2 " ;
2
+ var KLEEVERSION = "0.8.3 " ;
3
3
4
4
// src/default.options.js
5
5
function getDefaultOptions ( THREE ) {
6
6
return {
7
7
debugLevel : 0 ,
8
+ // 0,1,2,3
8
9
responsive : true ,
9
10
renderer : {
10
11
type : "WebGLRenderer" ,
11
- args : [ { antialias : true , preserveDrawingBuffer : true , alpha : true } ] ,
12
+ args : [ { antialias : true , preserveDrawingBuffer : true , alpha : true } ] ,
12
13
domElement : "body" ,
13
14
clearColor : "#000000" ,
14
15
opacity : 1 ,
15
16
properties : {
17
+ // outputEncoding: THREE.sRGBEncoding,
16
18
shadowMap : {
17
19
enabled : true ,
18
20
type : THREE . PCFSoftShadowMap
@@ -25,7 +27,7 @@ function getDefaultOptions(THREE) {
25
27
lookAt : [ 0 , 0 , 0 ]
26
28
} ,
27
29
properties : {
28
- position : { x : - 1 , y : 2 , z : 5 } ,
30
+ position : { x : - 1 , y : 2 , z : 5 } ,
29
31
name : "camera-1" ,
30
32
fov : 35 ,
31
33
aspect : window . innerWidth / window . innerHeight ,
@@ -37,14 +39,16 @@ function getDefaultOptions(THREE) {
37
39
type : "Scene" ,
38
40
properties : {
39
41
name : "scene-1" ,
40
- position : { x : 0 , y : 0 , z : 0 }
42
+ position : { x : 0 , y : 0 , z : 0 }
41
43
}
42
44
}
43
45
} ;
44
46
}
45
47
46
48
// src/utils.js
47
49
var Utils = class {
50
+ // https://gist.github.com/ahtcx/0cd94e62691f539160b32ecda18af3d6
51
+ // mutates target for read-only properties
48
52
static merge ( target , source ) {
49
53
if ( ! source || typeof source !== "object" ) {
50
54
return target ;
@@ -83,7 +87,7 @@ var Utils = class {
83
87
} ;
84
88
85
89
// src/modules/app.js
86
- var App = function ( ) {
90
+ var App = /* @__PURE__ */ function ( ) {
87
91
let options = { } ;
88
92
let THREE ;
89
93
const local = {
@@ -109,13 +113,13 @@ var App = function() {
109
113
if ( ! three || ! three . REVISION ) {
110
114
error ( "THREE is not inserted" ) ;
111
115
}
112
- THREE = { ...three } ;
116
+ THREE = { ...three } ;
113
117
if ( ! initOptions || typeof initOptions !== "object" ) {
114
118
initOptions = { } ;
115
119
warn ( "Options are set to default values" ) ;
116
120
}
117
121
const mergedOptions = Utils . merge ( getDefaultOptions ( THREE ) , initOptions ) ;
118
- options = { ...mergedOptions } ;
122
+ options = { ...mergedOptions } ;
119
123
local . renderer = initRenderer ( options . renderer ) ;
120
124
local . manager = new THREE . LoadingManager ( ) ;
121
125
}
@@ -296,85 +300,21 @@ var App = function() {
296
300
} ;
297
301
} ( ) ;
298
302
299
- // src/modules/material.js
300
- var Material = function ( ) {
301
- function create ( options ) {
302
- if ( ! options ) {
303
- options = {
304
- type : "MeshPhongMaterial" ,
305
- args : [ { color : 16777215 } ]
306
- } ;
307
- App . info ( "No options for material given, using default MeshPhongMaterial in white" ) ;
308
- }
309
- let material = App . create ( options ) ;
310
- material = change ( material , options ) ;
311
- return material ;
312
- }
313
- function change ( object , options ) {
314
- const THREE = App . THREE ;
315
- if ( options . properties ) {
316
- object = applyProperties ( object , options . properties ) ;
317
- }
318
- if ( options . methods ) {
319
- object = Utils . applyMethods ( object , options . methods ) ;
320
- }
321
- if ( options . textures ) {
322
- options . textures . forEach ( async ( texture ) => {
323
- const loaderType = texture . loader || "TextureLoader" ;
324
- const loader = new THREE [ loaderType ] ( App . manager ) ;
325
- const mapType = texture . map ;
326
- const mapTexture = await loader . loadAsync ( texture . url ) ;
327
- object [ mapType ] = mapTexture ;
328
- if ( texture . properties ) {
329
- object [ mapType ] = applyProperties ( object [ mapType ] , texture . properties ) ;
330
- }
331
- if ( texture . methods ) {
332
- object [ mapType ] = Utils . applyMethods ( object , texture . methods ) ;
333
- }
334
- } ) ;
335
- object . needsUpdate = true ;
336
- }
337
- return object ;
338
- }
339
- function applyProperties ( object , options ) {
340
- const THREE = App . THREE ;
341
- if ( ! options || typeof options !== "object" ) {
342
- return object ;
343
- }
344
- for ( const prop in options ) {
345
- if ( options [ prop ] instanceof Object ) {
346
- object [ prop ] = { ...options [ prop ] } ;
347
- } else {
348
- if ( Utils . isThreeColorValue ( prop ) ) {
349
- object [ prop ] = new THREE . Color ( options [ prop ] ) ;
350
- } else {
351
- object [ prop ] = options [ prop ] ;
352
- }
353
- }
354
- }
355
- return object ;
356
- }
357
- return {
358
- create,
359
- change
360
- } ;
361
- } ( App ) ;
362
-
363
303
// src/modules/userdata.js
364
- var UserData = function ( ) {
304
+ var UserData = /* @__PURE__ */ function ( ) {
365
305
function handle ( object , userData ) {
366
306
const f = {
367
307
collidable : ( action ) => addCollidables ( object , action ) ,
368
308
draggable : ( action ) => addDraggables ( object , action ) ,
369
- dragMaterial : ( action ) => createDragMaterial ( object , action ) ,
309
+ // dragMaterial: (action) => createDragMaterial(object, action),
370
310
movingLimiter : ( action ) => setMovingLimits ( object , action )
371
311
} ;
372
312
for ( const action in userData ) {
373
313
if ( userData [ action ] && f [ action ] ) {
374
314
f [ action ] ( action ) ;
375
315
}
376
316
}
377
- object . userData = { ...object . userData , ...userData } ;
317
+ object . userData = { ...object . userData , ...userData } ;
378
318
}
379
319
function setMovingLimits ( object , action ) {
380
320
const THREE = App . THREE ;
@@ -385,9 +325,6 @@ var UserData = function() {
385
325
max : boundingBox . max
386
326
} ;
387
327
}
388
- function createDragMaterial ( object , action ) {
389
- return ;
390
- }
391
328
function addDraggables ( object , action ) {
392
329
if ( action ) {
393
330
App . draggables . push ( object ) ;
@@ -404,7 +341,7 @@ var UserData = function() {
404
341
} ( App ) ;
405
342
406
343
// src/modules/object3d.js
407
- var Object3d = function ( ) {
344
+ var Object3d = /* @__PURE__ */ function ( ) {
408
345
function add ( options ) {
409
346
const object3d = create ( options ) ;
410
347
App . scene . add ( object3d ) ;
@@ -437,10 +374,10 @@ var Object3d = function() {
437
374
if ( "setFromVector3" in object [ prop ] ) {
438
375
const toVector3 = new THREE . Vector3 ( ) ;
439
376
toVector3 . setFromEuler ( object [ prop ] ) ;
440
- const mergedVector3 = { ...toVector3 , ...options [ prop ] } ;
377
+ const mergedVector3 = { ...toVector3 , ...options [ prop ] } ;
441
378
object [ prop ] . setFromVector3 ( mergedVector3 ) ;
442
379
}
443
- const v = { ...object [ prop ] , ...options [ prop ] } ;
380
+ const v = { ...object [ prop ] , ...options [ prop ] } ;
444
381
object [ prop ] . copy ( v ) ;
445
382
} else {
446
383
if ( prop === "userData" ) {
@@ -467,7 +404,7 @@ var Object3d = function() {
467
404
} ( App ) ;
468
405
469
406
// src/modules/scene.js
470
- var Scene = function ( ) {
407
+ var Scene = /* @__PURE__ */ function ( ) {
471
408
function init ( ) {
472
409
const options = App . options ;
473
410
App . camera = initCamera ( options . camera ) ;
@@ -503,7 +440,7 @@ var Scene = function() {
503
440
} ( App ) ;
504
441
505
442
// src/modules/controls.js
506
- var Controls = function ( ) {
443
+ var Controls = /* @__PURE__ */ function ( ) {
507
444
function init ( Controls2 , options ) {
508
445
App . controls [ Controls2 . name ] = initControls ( Controls2 , options ) ;
509
446
}
@@ -518,7 +455,7 @@ var Controls = function() {
518
455
} ( App ) ;
519
456
520
457
// src/modules/loaders.js
521
- var Loaders = function ( ) {
458
+ var Loaders = /* @__PURE__ */ function ( ) {
522
459
const Loaders2 = { } ;
523
460
function init ( LoaderClass ) {
524
461
Loaders2 [ LoaderClass . name ] = new LoaderClass ( App . manager ) ;
@@ -534,7 +471,7 @@ var Loaders = function() {
534
471
} ( App ) ;
535
472
536
473
// src/modules/light.js
537
- var Light = function ( ) {
474
+ var Light = /* @__PURE__ */ function ( ) {
538
475
function create ( options ) {
539
476
const light = Object3d . create ( options ) ;
540
477
return light ;
@@ -568,8 +505,72 @@ var Light = function() {
568
505
} ;
569
506
} ( App ) ;
570
507
508
+ // src/modules/material.js
509
+ var Material = /* @__PURE__ */ function ( ) {
510
+ function create ( options ) {
511
+ if ( ! options ) {
512
+ options = {
513
+ type : "MeshPhongMaterial" ,
514
+ args : [ { color : 16777215 } ]
515
+ } ;
516
+ App . info ( "No options for material given, using default MeshPhongMaterial in white" ) ;
517
+ }
518
+ let material = App . create ( options ) ;
519
+ material = change ( material , options ) ;
520
+ return material ;
521
+ }
522
+ function change ( object , options ) {
523
+ const THREE = App . THREE ;
524
+ if ( options . properties ) {
525
+ object = applyProperties ( object , options . properties ) ;
526
+ }
527
+ if ( options . methods ) {
528
+ object = Utils . applyMethods ( object , options . methods ) ;
529
+ }
530
+ if ( options . textures ) {
531
+ options . textures . forEach ( async ( texture ) => {
532
+ const loaderType = texture . loader || "TextureLoader" ;
533
+ const loader = new THREE [ loaderType ] ( App . manager ) ;
534
+ const mapType = texture . map ;
535
+ const mapTexture = await loader . loadAsync ( texture . url ) ;
536
+ object [ mapType ] = mapTexture ;
537
+ if ( texture . properties ) {
538
+ object [ mapType ] = applyProperties ( object [ mapType ] , texture . properties ) ;
539
+ }
540
+ if ( texture . methods ) {
541
+ object [ mapType ] = Utils . applyMethods ( object , texture . methods ) ;
542
+ }
543
+ } ) ;
544
+ object . needsUpdate = true ;
545
+ }
546
+ return object ;
547
+ }
548
+ function applyProperties ( object , options ) {
549
+ const THREE = App . THREE ;
550
+ if ( ! options || typeof options !== "object" ) {
551
+ return object ;
552
+ }
553
+ for ( const prop in options ) {
554
+ if ( options [ prop ] instanceof Object ) {
555
+ object [ prop ] = { ...options [ prop ] } ;
556
+ } else {
557
+ if ( Utils . isThreeColorValue ( prop ) ) {
558
+ object [ prop ] = new THREE . Color ( options [ prop ] ) ;
559
+ } else {
560
+ object [ prop ] = options [ prop ] ;
561
+ }
562
+ }
563
+ }
564
+ return object ;
565
+ }
566
+ return {
567
+ create,
568
+ change
569
+ } ;
570
+ } ( App ) ;
571
+
571
572
// src/modules/geometry.js
572
- var Geometry = function ( ) {
573
+ var Geometry = /* @__PURE__ */ function ( ) {
573
574
function create ( options ) {
574
575
if ( ! options ) {
575
576
options = {
@@ -588,7 +589,7 @@ var Geometry = function() {
588
589
} ( App ) ;
589
590
590
591
// src/modules/item.js
591
- var Item = function ( ) {
592
+ var Item = /* @__PURE__ */ function ( ) {
592
593
function create ( options ) {
593
594
const THREE = App . THREE ;
594
595
const material = Material . create ( options . material ) ;
@@ -691,7 +692,7 @@ var Item = function() {
691
692
} ( App ) ;
692
693
693
694
// src/modules/dragging.js
694
- var Dragging = function ( ) {
695
+ var Dragging = /* @__PURE__ */ function ( ) {
695
696
let tmpMaterial = null ;
696
697
let plane = null ;
697
698
let planeNormal = null ;
@@ -790,7 +791,7 @@ var Dragging = function() {
790
791
} ( ) ;
791
792
792
793
// src/modules/events.js
793
- var Events = function ( ) {
794
+ var Events = /* @__PURE__ */ function ( ) {
794
795
async function init ( ) {
795
796
const THREE = App . THREE ;
796
797
App . raycaster = App . raycaster ?? new THREE . Raycaster ( ) ;
@@ -826,7 +827,7 @@ var Events = function() {
826
827
} ( ) ;
827
828
828
829
// src/modules/collisions.js
829
- var Collision = function ( ) {
830
+ var Collision = /* @__PURE__ */ function ( ) {
830
831
const currentCollisions = [ ] ;
831
832
function check ( object , onlyVisible = true ) {
832
833
const THREE = App . THREE ;
0 commit comments