Selaa lähdekoodia

Merge pull request #3009 from RaananW/viewr-0.1

Viewer - small fixes and cleanup
Raanan Weber 7 vuotta sitten
vanhempi
commit
f168deca38

+ 1 - 1
Viewer/dist/basicExample.html

@@ -16,7 +16,7 @@
 
     <body>
         <babylon model.title="The Bus!" model.subtitle="Remix3D" model.thumbnail="http://d33wubrfki0l68.cloudfront.net/7e08139ddee0ec38005f4232346c7f7386831300/fd934/githubuniverse/remix3d.png"
-            model.url="https://ugcorigin.s-microsoft.com/12/2e77b8e3-0000-0000-7a48-6505db2f0ef9/952/1508427934473.gltf" default-viewer="true"></babylon>
+            model.url="http://playground.babylonjs.com/scenes/Rabbit.babylon" default-viewer="true"></babylon>
         <script src="viewer.js"></script>
     </body>
 

+ 7 - 0
Viewer/dist/domExample.html

@@ -24,6 +24,13 @@
                     <behavior type="0"></behavior>
                 </behaviors>
             </camera>
+            <lights array="true">
+                <light type="1" shadow-enabled="true" position.y="0.5" direction.y="-1" intensity="4.5">
+                    <shadow-config use-blur-exponential-shadow-map="true" use-kernel-blur="true" blur-kernel="64" blur-scale="4">
+
+                    </shadow-config>
+                </light>
+            </lights>
         </babylon>
         <script src="viewer.js"></script>
     </body>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 173 - 50
Viewer/dist/viewer.js


+ 4 - 5
Viewer/src/configuration/configuration.ts

@@ -212,12 +212,12 @@ export let defaultConfiguration: ViewerConfiguration = {
             }
         ]
     },
-    lights: [
+    /*lights: [
         {
             type: 1,
             shadowEnabled: true,
             direction: { x: -0.2, y: -1, z: 0 },
-            position: { x: 0.017, y: 0.5, z: 0 },
+            position: { x: 0.017, y: 50, z: 0 },
             intensity: 4.5,
             shadowConfig: {
                 useBlurExponentialShadowMap: true,
@@ -226,15 +226,14 @@ export let defaultConfiguration: ViewerConfiguration = {
                 blurScale: 4
             }
         }
-    ],
+    ],*/
     skybox: {
         cubeTexture: {
-            url: 'http://localhost:9000/environment.dds',
+            url: 'https://playground.babylonjs.com/textures/environment.dds',
             gammaSpace: false
         },
         pbr: true,
         blur: 0.7,
-        scale: 32,
         infiniteDIstance: false,
         material: {
             imageProcessingConfiguration: {

+ 14 - 3
Viewer/src/configuration/mappers.ts

@@ -22,7 +22,18 @@ class HTMLMapper implements IMapper {
                 //convert html-style to json-style
                 let camelKey = kebabToCamel(key);
                 if (idx === split.length - 1) {
-                    currentConfig[camelKey] = attr.nodeValue;
+                    let val: any = attr.nodeValue;
+                    if (val === "true") {
+                        val = true;
+                    } else if (val === "false") {
+                        val = false;
+                    } else {
+                        let number = parseFloat(val);
+                        if (!isNaN(number)) {
+                            val = number;
+                        }
+                    }
+                    currentConfig[camelKey] = val;
                 } else {
                     currentConfig[camelKey] = currentConfig[camelKey] || {};
                 }
@@ -52,11 +63,11 @@ class DOMMapper implements IMapper {
             if (children.length) {
                 for (let i = 0; i < children.length; ++i) {
                     let item = <HTMLElement>children.item(i);
+                    let configMapped = htmlMapper.map(item);
                     let key = kebabToCamel(item.nodeName.toLowerCase());
                     if (item.attributes.getNamedItem('array') && item.attributes.getNamedItem('array').nodeValue === 'true') {
                         partConfig[key] = [];
                     } else {
-                        let configMapped = htmlMapper.map(item);
                         if (element.attributes.getNamedItem('array') && element.attributes.getNamedItem('array').nodeValue === 'true') {
                             partConfig.push(configMapped)
                         } else if (partConfig[key]) {
@@ -68,7 +79,7 @@ class DOMMapper implements IMapper {
                             partConfig[key] = configMapped;
                         }
                     }
-                    traverseChildren(item, partConfig[key]);
+                    traverseChildren(item, partConfig[key] || configMapped);
                 }
             }
             return partConfig;

+ 2 - 2
Viewer/src/viewer/defaultViewer.ts

@@ -160,9 +160,9 @@ export class DefaultViewer extends AbstractViewer {
         if (this.configuration.ground) {
             let groundConfig = (typeof this.configuration.ground === 'boolean') ? {} : this.configuration.ground;
 
-            var ground = Mesh.CreateGround('ground', groundConfig.size || 100, groundConfig.size || 100, 8, this.scene);
+            var ground = Mesh.CreateGround('ground', groundConfig.size || 1000, groundConfig.size || 1000, 8, this.scene);
             if (this.configuration.ground === true || groundConfig.shadowOnly) {
-                ground.material = new BABYLON.ShadowOnlyMaterial('groundmat', this.scene);
+                ground.material = new ShadowOnlyMaterial('groundmat', this.scene);
             } else {
                 ground.material = new StandardMaterial('groundmat', this.scene);
             }