David Catuhe 7 年之前
父節點
當前提交
eb8deeed82

File diff suppressed because it is too large
+ 11098 - 10986
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 13718 - 13610
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 52 - 52
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 472 - 137
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 472 - 137
dist/preview release/babylon.no-module.max.js


File diff suppressed because it is too large
+ 22 - 22
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 474 - 139
dist/preview release/es6.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/inspector/babylon.inspector.bundle.js


+ 4 - 0
dist/preview release/viewer/babylon.viewer.d.ts

@@ -168,6 +168,7 @@ declare module BabylonViewer {
                 * This will be executed when the templates initialize.
                 */
             protected _onTemplatesLoaded(): Promise<AbstractViewer>;
+            toggleHD(): void;
             /**
                 * Toggle fullscreen of the entire viewer
                 */
@@ -366,6 +367,8 @@ declare module BabylonViewer {
                 * force resizing the engine.
                 */
             forceResize(): void;
+            protected _hdToggled: boolean;
+            toggleHD(): void;
             /**
                 * The resize function that will be registered with the window object
                 */
@@ -986,6 +989,7 @@ declare module BabylonViewer {
                     disableResize?: boolean;
                     engineOptions?: BABYLON.EngineOptions;
                     adaptiveQuality?: boolean;
+                    hdEnabled?: boolean;
             };
             templates?: {
                     main: ITemplateConfiguration;

File diff suppressed because it is too large
+ 41 - 41
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 521 - 145
dist/preview release/viewer/babylon.viewer.max.js


+ 4 - 0
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -168,6 +168,7 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * This will be executed when the templates initialize.
                 */
             protected _onTemplatesLoaded(): Promise<AbstractViewer>;
+            toggleHD(): void;
             /**
                 * Toggle fullscreen of the entire viewer
                 */
@@ -366,6 +367,8 @@ declare module 'babylonjs-viewer/viewer/viewer' {
                 * force resizing the engine.
                 */
             forceResize(): void;
+            protected _hdToggled: boolean;
+            toggleHD(): void;
             /**
                 * The resize function that will be registered with the window object
                 */
@@ -986,6 +989,7 @@ declare module 'babylonjs-viewer/configuration/configuration' {
                     disableResize?: boolean;
                     engineOptions?: EngineOptions;
                     adaptiveQuality?: boolean;
+                    hdEnabled?: boolean;
             };
             templates?: {
                     main: ITemplateConfiguration;

+ 33 - 29
src/Particles/babylon.particleSystem.ts

@@ -366,7 +366,7 @@
         private _stopped = false;
         private _actualFrame = 0;
         private _scaledUpdateSpeed: number;
-        private _vertexBufferSize = 12;
+        private _vertexBufferSize: number;
         private _isAnimationSheetEnabled: boolean;
         private _isBillboardBased = true;
 
@@ -495,27 +495,19 @@
             this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
             this._vertexBuffer = new Buffer(engine, this._vertexData, true, this._vertexBufferSize);
 
-            var positions = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, 0, 3, this._vertexBufferSize, this._useInstancing);
+            let dataOffset = 0;        
+            var positions = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
             this._vertexBuffers[VertexBuffer.PositionKind] = positions;
+            dataOffset += 3;
 
-            var colors = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, 3, 4, this._vertexBufferSize, this._useInstancing);
+            var colors = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
             this._vertexBuffers[VertexBuffer.ColorKind] = colors;
+            dataOffset += 4;
 
-            var options = this._vertexBuffer.createVertexBuffer("angle", 7, 1, this._vertexBufferSize, this._useInstancing);
+            var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
             this._vertexBuffers["angle"] = options;
+            dataOffset += 1;
             
-            var offsets: VertexBuffer;
-            let dataOffset = 8;
-            if (this._useInstancing) {
-                var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);  
-                this._spriteBuffer = new Buffer(engine, spriteData, false, 2);  
-                offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
-            } else {
-                offsets = this._vertexBuffer.createVertexBuffer("offset", 8, 2, this._vertexBufferSize, this._useInstancing);
-                dataOffset += 2;
-            }
-            this._vertexBuffers["offset"] = offsets;            
-
             var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
             this._vertexBuffers["size"] = size;
             dataOffset += 2;
@@ -531,6 +523,17 @@
                 this._vertexBuffers["direction"] = directionBuffer;
                 dataOffset += 3;
             }
+
+            var offsets: VertexBuffer;
+            if (this._useInstancing) {
+                var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);  
+                this._spriteBuffer = new Buffer(engine, spriteData, false, 2);  
+                offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
+            } else {
+                offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
+                dataOffset += 2;
+            }
+            this._vertexBuffers["offset"] = offsets;              
         }
 
         private _createIndexBuffer() {
@@ -625,6 +628,19 @@
             this._vertexData[offset++] = particle.color.a;
             this._vertexData[offset++] = particle.angle;
 
+            this._vertexData[offset++] = particle.scale.x * particle.size;
+            this._vertexData[offset++] = particle.scale.y * particle.size;
+            
+            if (this._isAnimationSheetEnabled) {
+                this._vertexData[offset++] = particle.cellIndex;
+            }
+
+            if (!this._isBillboardBased) {
+                this._vertexData[offset++] = particle.direction.x;
+                this._vertexData[offset++] = particle.direction.y;
+                this._vertexData[offset++] = particle.direction.z;
+            }
+
             if (!this._useInstancing) {
                 if (this._isAnimationSheetEnabled) {
                     if (offsetX === 0)
@@ -641,19 +657,6 @@
                 this._vertexData[offset++] = offsetX;
                 this._vertexData[offset++] = offsetY;   
             }
-
-            this._vertexData[offset++] = particle.scale.x * particle.size;
-            this._vertexData[offset++] = particle.scale.y * particle.size;
-            
-            if (this._isAnimationSheetEnabled) {
-                this._vertexData[offset++] = particle.cellIndex;
-            }
-
-            if (!this._isBillboardBased) {
-                this._vertexData[offset++] = particle.direction.x;
-                this._vertexData[offset++] = particle.direction.y;
-                this._vertexData[offset++] = particle.direction.z;
-            }
         }
 
         // start of sub system methods
@@ -990,6 +993,7 @@
 
             if (this._useInstancing) {
                 engine.drawArraysType(Material.TriangleFanDrawMode, 0, 4, this._particles.length);  
+                engine.unbindInstanceAttributes();
             } else {
                 engine.drawElementsType(Material.TriangleFillMode, 0, this._particles.length * 6);
             }

+ 2 - 2
src/Shaders/particles.vertex.fx

@@ -2,7 +2,6 @@
 attribute vec3 position;
 attribute vec4 color;
 attribute float angle;
-attribute vec2 offset;
 attribute vec2 size;
 #ifdef ANIMATESHEET	
 attribute float cellIndex;
@@ -10,6 +9,7 @@ attribute float cellIndex;
 #ifndef BILLBOARD	
 attribute vec3 direction;
 #endif
+attribute vec2 offset;
 
 // Uniforms
 uniform mat4 view;
@@ -54,7 +54,7 @@ void main(void) {
 
 	vec3 worldPos = position + rotatedCorner; 
 
-	vec3 yaxis = normalize(direction);
+	vec3 yaxis = normalize(position);
 	vec3 xaxis = normalize(cross(vec3(0., 1.0, 0.), yaxis));
 	vec3 zaxis = normalize(cross(yaxis, xaxis));