diff --git a/demo/index.html b/demo/index.html
index cf45e4e..16149aa 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -11,6 +11,7 @@
+
@@ -111,6 +112,44 @@
Zoom
+ Light
+
+
+
+
+
+
+
+
+
+
+
+ |
+ [[ambientLightIntensity]] |
+ |
+
+
+ |
+ [[directionalLightIntensity]] |
+ |
+
+
+
+
+
+
+
+
+
+
🗒 Note: The used texture pack "Faithful 32x32 Pack" (Link) was made by "Vattic".
diff --git a/voxel-visualization.js b/voxel-visualization.js
index 94745e2..242fa4f 100644
--- a/voxel-visualization.js
+++ b/voxel-visualization.js
@@ -35,6 +35,16 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe
{
type: Number,
value: 1
+ },
+ ambientLightIntensity:
+ {
+ type: Number,
+ value: 0.5
+ },
+ directionalLightIntensity:
+ {
+ type: Number,
+ value: 0.5
}
};
}
@@ -45,7 +55,9 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe
'_onSchematicJsonPathChanged(schematicJsonPath)',
'_onSchematicPathChanged(schematicPath)',
'_onSchematicChanged(schematic)',
- '_onTexturePackPathChanged(texturePackPath)'
+ '_onTexturePackPathChanged(texturePackPath)',
+ '_onAmbientLightIntensityChanged(ambientLightIntensity)',
+ '_onDirectionalLightIntensityChanged(directionalLightIntensity)'
]
}
@@ -90,6 +102,22 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe
});
}
+ _onAmbientLightIntensityChanged(ambientLightIntensity)
+ {
+ let normalizedAmbientLightIntensity = parseInt(this.ambientLightIntensity * 0xff);
+ let ambientLightColor = normalizedAmbientLightIntensity * 0x010101;
+
+ this.ambientLight.color.set(ambientLightColor);
+ }
+
+ _onDirectionalLightIntensityChanged(directionalLightIntensity)
+ {
+ let normalizedDirectionalLightIntensity = parseInt(this.directionalLightIntensity * 0xff);
+ let directionalLightColor = normalizedDirectionalLightIntensity * 0x010101;
+
+ this.directionalLight.color.set(directionalLightColor);
+ }
+
_onSchematicPathChanged(schematicPath)
{
let file = this.baseURI + schematicPath;
@@ -162,11 +190,17 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe
this.scene = new THREE.Scene();
- var ambientLight = new THREE.AmbientLight(0xdddddd);
- var PointLight = new THREE.PointLight(0xffffff, 0.15);
+ let normalizedAmbientLightIntensity = parseInt(this.ambientLightIntensity * 0xff);
+ let ambientLightColor = normalizedAmbientLightIntensity * 0x010101;
+ this.ambientLight = new THREE.AmbientLight(ambientLightColor);
+
+ let normalizedDirectionalLightIntensity = parseInt(this.directionalLightIntensity * 0xff);
+ let directionalLightColor = normalizedDirectionalLightIntensity * 0x010101;
+ this.directionalLight = new THREE.DirectionalLight(directionalLightColor, 2);
+ this.directionalLight.position.set(2, 4, 5);
- this.scene.add(ambientLight);
- this.scene.add(PointLight);
+ this.scene.add(this.ambientLight);
+ this.scene.add(this.directionalLight);
if(schematic)
{