Skip to content

Commit b49b980

Browse files
authored
Merge pull request #39 from trenc/fix/updated
refactor: update libs, apply some styles
2 parents 3bb06fc + 796868e commit b49b980

25 files changed

+1203
-1289
lines changed

dist/klee.js

+90-89
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
// src/modules/constants.js
2-
var KLEEVERSION = "0.8.2";
2+
var KLEEVERSION = "0.8.3";
33

44
// src/default.options.js
55
function getDefaultOptions(THREE) {
66
return {
77
debugLevel: 0,
8+
// 0,1,2,3
89
responsive: true,
910
renderer: {
1011
type: "WebGLRenderer",
11-
args: [{antialias: true, preserveDrawingBuffer: true, alpha: true}],
12+
args: [{ antialias: true, preserveDrawingBuffer: true, alpha: true }],
1213
domElement: "body",
1314
clearColor: "#000000",
1415
opacity: 1,
1516
properties: {
17+
// outputEncoding: THREE.sRGBEncoding,
1618
shadowMap: {
1719
enabled: true,
1820
type: THREE.PCFSoftShadowMap
@@ -25,7 +27,7 @@ function getDefaultOptions(THREE) {
2527
lookAt: [0, 0, 0]
2628
},
2729
properties: {
28-
position: {x: -1, y: 2, z: 5},
30+
position: { x: -1, y: 2, z: 5 },
2931
name: "camera-1",
3032
fov: 35,
3133
aspect: window.innerWidth / window.innerHeight,
@@ -37,14 +39,16 @@ function getDefaultOptions(THREE) {
3739
type: "Scene",
3840
properties: {
3941
name: "scene-1",
40-
position: {x: 0, y: 0, z: 0}
42+
position: { x: 0, y: 0, z: 0 }
4143
}
4244
}
4345
};
4446
}
4547

4648
// src/utils.js
4749
var Utils = class {
50+
// https://gist.github.com/ahtcx/0cd94e62691f539160b32ecda18af3d6
51+
// mutates target for read-only properties
4852
static merge(target, source) {
4953
if (!source || typeof source !== "object") {
5054
return target;
@@ -83,7 +87,7 @@ var Utils = class {
8387
};
8488

8589
// src/modules/app.js
86-
var App = function() {
90+
var App = /* @__PURE__ */ function() {
8791
let options = {};
8892
let THREE;
8993
const local = {
@@ -109,13 +113,13 @@ var App = function() {
109113
if (!three || !three.REVISION) {
110114
error("THREE is not inserted");
111115
}
112-
THREE = {...three};
116+
THREE = { ...three };
113117
if (!initOptions || typeof initOptions !== "object") {
114118
initOptions = {};
115119
warn("Options are set to default values");
116120
}
117121
const mergedOptions = Utils.merge(getDefaultOptions(THREE), initOptions);
118-
options = {...mergedOptions};
122+
options = { ...mergedOptions };
119123
local.renderer = initRenderer(options.renderer);
120124
local.manager = new THREE.LoadingManager();
121125
}
@@ -296,85 +300,21 @@ var App = function() {
296300
};
297301
}();
298302

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-
363303
// src/modules/userdata.js
364-
var UserData = function() {
304+
var UserData = /* @__PURE__ */ function() {
365305
function handle(object, userData) {
366306
const f = {
367307
collidable: (action) => addCollidables(object, action),
368308
draggable: (action) => addDraggables(object, action),
369-
dragMaterial: (action) => createDragMaterial(object, action),
309+
// dragMaterial: (action) => createDragMaterial(object, action),
370310
movingLimiter: (action) => setMovingLimits(object, action)
371311
};
372312
for (const action in userData) {
373313
if (userData[action] && f[action]) {
374314
f[action](action);
375315
}
376316
}
377-
object.userData = {...object.userData, ...userData};
317+
object.userData = { ...object.userData, ...userData };
378318
}
379319
function setMovingLimits(object, action) {
380320
const THREE = App.THREE;
@@ -385,9 +325,6 @@ var UserData = function() {
385325
max: boundingBox.max
386326
};
387327
}
388-
function createDragMaterial(object, action) {
389-
return;
390-
}
391328
function addDraggables(object, action) {
392329
if (action) {
393330
App.draggables.push(object);
@@ -404,7 +341,7 @@ var UserData = function() {
404341
}(App);
405342

406343
// src/modules/object3d.js
407-
var Object3d = function() {
344+
var Object3d = /* @__PURE__ */ function() {
408345
function add(options) {
409346
const object3d = create(options);
410347
App.scene.add(object3d);
@@ -437,10 +374,10 @@ var Object3d = function() {
437374
if ("setFromVector3" in object[prop]) {
438375
const toVector3 = new THREE.Vector3();
439376
toVector3.setFromEuler(object[prop]);
440-
const mergedVector3 = {...toVector3, ...options[prop]};
377+
const mergedVector3 = { ...toVector3, ...options[prop] };
441378
object[prop].setFromVector3(mergedVector3);
442379
}
443-
const v = {...object[prop], ...options[prop]};
380+
const v = { ...object[prop], ...options[prop] };
444381
object[prop].copy(v);
445382
} else {
446383
if (prop === "userData") {
@@ -467,7 +404,7 @@ var Object3d = function() {
467404
}(App);
468405

469406
// src/modules/scene.js
470-
var Scene = function() {
407+
var Scene = /* @__PURE__ */ function() {
471408
function init() {
472409
const options = App.options;
473410
App.camera = initCamera(options.camera);
@@ -503,7 +440,7 @@ var Scene = function() {
503440
}(App);
504441

505442
// src/modules/controls.js
506-
var Controls = function() {
443+
var Controls = /* @__PURE__ */ function() {
507444
function init(Controls2, options) {
508445
App.controls[Controls2.name] = initControls(Controls2, options);
509446
}
@@ -518,7 +455,7 @@ var Controls = function() {
518455
}(App);
519456

520457
// src/modules/loaders.js
521-
var Loaders = function() {
458+
var Loaders = /* @__PURE__ */ function() {
522459
const Loaders2 = {};
523460
function init(LoaderClass) {
524461
Loaders2[LoaderClass.name] = new LoaderClass(App.manager);
@@ -534,7 +471,7 @@ var Loaders = function() {
534471
}(App);
535472

536473
// src/modules/light.js
537-
var Light = function() {
474+
var Light = /* @__PURE__ */ function() {
538475
function create(options) {
539476
const light = Object3d.create(options);
540477
return light;
@@ -568,8 +505,72 @@ var Light = function() {
568505
};
569506
}(App);
570507

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+
571572
// src/modules/geometry.js
572-
var Geometry = function() {
573+
var Geometry = /* @__PURE__ */ function() {
573574
function create(options) {
574575
if (!options) {
575576
options = {
@@ -588,7 +589,7 @@ var Geometry = function() {
588589
}(App);
589590

590591
// src/modules/item.js
591-
var Item = function() {
592+
var Item = /* @__PURE__ */ function() {
592593
function create(options) {
593594
const THREE = App.THREE;
594595
const material = Material.create(options.material);
@@ -691,7 +692,7 @@ var Item = function() {
691692
}(App);
692693

693694
// src/modules/dragging.js
694-
var Dragging = function() {
695+
var Dragging = /* @__PURE__ */ function() {
695696
let tmpMaterial = null;
696697
let plane = null;
697698
let planeNormal = null;
@@ -790,7 +791,7 @@ var Dragging = function() {
790791
}();
791792

792793
// src/modules/events.js
793-
var Events = function() {
794+
var Events = /* @__PURE__ */ function() {
794795
async function init() {
795796
const THREE = App.THREE;
796797
App.raycaster = App.raycaster ?? new THREE.Raycaster();
@@ -826,7 +827,7 @@ var Events = function() {
826827
}();
827828

828829
// src/modules/collisions.js
829-
var Collision = function() {
830+
var Collision = /* @__PURE__ */ function() {
830831
const currentCollisions = [];
831832
function check(object, onlyVisible = true) {
832833
const THREE = App.THREE;

0 commit comments

Comments
 (0)