Skip to content

Commit 2e65fa3

Browse files
committed
new lightning and three.js 162
1 parent f77173a commit 2e65fa3

File tree

2 files changed

+12
-53
lines changed

2 files changed

+12
-53
lines changed

index.html

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,6 @@ <h1>Prototype Viewer MediaWiki 3D GLTF Data, STL data is already available </h1>
125125

126126
const TD = ThreeD.prototype;
127127

128-
129-
TD.addShadowedLight = function (x, y, z, color, intensity) {
130-
131-
const directionalLight = new THREE.DirectionalLight(color, intensity);
132-
directionalLight.position.set(x, y, z);
133-
directionalLight.castShadow = true;
134-
directionalLight.shadow.mapSize.width = 4096;
135-
directionalLight.shadow.mapSize.height = 4096;
136-
directionalLight.shadow.camera.near = 1;
137-
directionalLight.shadow.camera.far = 50;
138-
directionalLight.color.setHSL(0.1, 1, 0.95);
139-
/*
140-
lightHelper = new THREE.DirectionalLightHelper( directionalLight );
141-
this.scene.add( lightHelper );
142-
*/
143-
this.scene.add(directionalLight);
144-
}
145-
146-
147128
TD.getBoxSizeCenter = function (object) {
148129
// compute the box that contains the object (and objects in the graph below)
149130
const box = new THREE.Box3().setFromObject(object);
@@ -216,27 +197,22 @@ <h1>Prototype Viewer MediaWiki 3D GLTF Data, STL data is already available </h1>
216197
this.controls.addEventListener('change', this.render.bind(this));
217198
this.controls.addEventListener('start', this.controlsStart.bind(this));
218199
this.controls.addEventListener('end', this.controlsEnd.bind(this));
200+
219201
// Scene and RoomEnvironment
220-
this.scene = new THREE.Scene();
221-
this.scene.add(this.camera);
222-
this.scene.add(new THREE.AmbientLight(0x666666, 2.5));
223-
const environment = new THREE.RoomEnvironment();
202+
const environment = new THREE.RoomEnvironment(this.renderer);
224203
const pmremGenerator = new THREE.PMREMGenerator(this.renderer);
204+
this.scene = new THREE.Scene();
205+
//this.scene.background = new THREE.Color(0xbbbbbb);
206+
this.scene.background = new THREE.Color(0x0000000);
225207
this.scene.environment = pmremGenerator.fromScene(environment).texture;
226208
environment.dispose();
227-
// shadowedLigt
228-
TD.addShadowedLight(1, 1, 1, 0xffffff, 3.5);
229-
// multi lights possible, looks better
230-
TD.addShadowedLight(-1, 0.5, -0.5, 0xffffff, 1.5);
231209
TD.load('stl', model, source);
232210

233211
};
234212

235213

236214
TD.initGLB = function (model, source) {
237-
238215
this.modeltype = modeltype;
239-
240216
if (document.getElementById('container')) {
241217

242218
this.scene.clear();
@@ -266,23 +242,13 @@ <h1>Prototype Viewer MediaWiki 3D GLTF Data, STL data is already available </h1>
266242
this.controls.addEventListener('start', this.controlsStart.bind(this));
267243
this.controls.addEventListener('end', this.controlsEnd.bind(this));
268244
// Scene and RoomEnvironment
269-
const environment = new THREE.RoomEnvironment();
245+
const environment = new THREE.RoomEnvironment(this.renderer);
270246
const pmremGenerator = new THREE.PMREMGenerator(this.renderer);
271247
this.scene = new THREE.Scene();
272-
this.scene.add(this.camera);
273-
this.scene.add(new THREE.AmbientLight(0x666666, 3.5));
274248
this.scene.background = new THREE.Color(0xbbbbbb);
249+
//this.scene.background = new THREE.Color(0x0000000);
275250
this.scene.environment = pmremGenerator.fromScene(environment).texture;
276251
environment.dispose();
277-
TD.addShadowedLight(1, 1, 1, 0xffffff, 3.5);
278-
// helper for testing
279-
/*
280-
const grid = new THREE.GridHelper(500, 10, 0xffffff, 0xffffff);
281-
grid.material.opacity = 0.5;
282-
grid.material.depthWrite = false;
283-
grid.material.transparent = true;
284-
this.scene.add(grid);
285-
*/
286252
TD.load('glb', model, source);
287253
};
288254

@@ -317,16 +283,10 @@ <h1>Prototype Viewer MediaWiki 3D GLTF Data, STL data is already available </h1>
317283

318284
// STL Material wird Geometry hinzugefügt
319285
TD.geometryToObject = function (geometry) {
320-
const material = new THREE.MeshPhongMaterial(
321-
{
322-
color: 0xf0ebe8,
323-
shininess: 5,
324-
flatShading: true,
325-
side: THREE.DoubleSide,
326-
// below used to be implicit, but that changed in
327-
// @see https://github.com/mrdoob/three.js/pull/13035/files
328-
shadowSide: THREE.BackSide
329-
}
286+
287+
const vertexColors = geometry.hasAttribute('color');
288+
const material = new THREE.MeshStandardMaterial(
289+
{ color: 0xf0ebe8, flatShading: true, side: THREE.DoubleSide, vertexColors }
330290
);
331291
return new THREE.Mesh(geometry, material);
332292
};
@@ -384,7 +344,6 @@ <h1>Prototype Viewer MediaWiki 3D GLTF Data, STL data is already available </h1>
384344
object.scene.traverse(function (node) {
385345
console.log(node);
386346
if (node.material) {
387-
//alert('material');
388347
node.material.side = THREE.DoubleSide;
389348
}
390349
if (node.mesh) {

lib/three/three_all_in.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)