]> gitweb.ps.run Git - cloth_sim/blobdiff - Scripts/main.js
change material
[cloth_sim] / Scripts / main.js
index ececd6af5bda8d4546a29fc286c73f08a78f3a6f..4e7c2ef7bb32e51f874a950f2697f75586f547e4 100644 (file)
@@ -1,6 +1,14 @@
 import { Face, Spring, Cloth } from './cloth.js';\r
 \r
 \r
+/**\r
+ * rendering\r
+ * Einheiten konsistent\r
+ * Wind\r
+ * evtl. an Stoff ziehen\r
+ */\r
+\r
+\r
 class Point {\r
   constructor(x, y) {\r
     this.x = x;\r
@@ -76,7 +84,8 @@ function init() {
   cloth.createBasic(10, 10, 10, 10);\r
   //cloth.createDebugMesh(scene);\r
 \r
-  const material = new THREE.MeshBasicMaterial({ color: 0x0000ff });\r
+  //const material = new THREE.MeshBasicMaterial({ color: 0x0000ff, side: THREE.DoubleSide });\r
+  const material = new THREE.MeshPhongMaterial({ color: 0x0000ff, side: THREE.DoubleSide });\r
   const mesh = new THREE.Mesh(cloth.geometry, material);\r
   //const mesh = new THREE.WireframeGeometry(cloth.geometry);\r
   //const line = new THREE.LineSegments(mesh);\r
@@ -85,12 +94,18 @@ function init() {
   //line.material.transparent = true;\r
   scene.add(mesh);\r
 \r
+  scene.add( new THREE.AmbientLight( 0x666666 ) );\r
+\r
+  const light = new THREE.DirectionalLight( 0xffffff, 0.5 );\r
+  light.position.set( 0, 1, 0.5 );\r
+  scene.add( light );\r
+\r
   /**\r
    * function called every frame\r
-   * @param {number} dt - time passed since last frame\r
+   * @param {number} dt - time passed since last frame in ms\r
    */\r
   function animate(dt) {\r
-    cloth.simulate(dt);\r
+    cloth.simulate(dt/1000);\r
 \r
     setTimeout(() => {\r
       animate(frameTime);\r