|
@@ -23,6 +23,9 @@
|
|
|
|
|
|
var __decorate=this&&this.__decorate||function(e,t,r,c){var o,f=arguments.length,n=f<3?t:null===c?c=Object.getOwnPropertyDescriptor(t,r):c;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,c);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(n=(f<3?o(n):f>3?o(t,r,n):o(t,r))||n);return f>3&&n&&Object.defineProperty(t,r,n),n};
|
|
|
var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)o.hasOwnProperty(n)&&(t[n]=o[n])};return function(o,n){function r(){this.constructor=o}t(o,n),o.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();
|
|
|
+BABYLON.Effect.ShadersStore['fluentVertexShader'] = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nuniform mat4 emissiveMatrix;\nvarying vec2 vEmissiveUV;\nvoid main(void) {\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\ngl_Position=viewProjection*world*vec4(position,1.0);\n}\n";
|
|
|
+BABYLON.Effect.ShadersStore['fluentPixelShader'] = "precision highp float;\nvarying vec2 vEmissiveUV;\nuniform sampler2D emissiveSampler;\nvoid main(void) {\nvec3 emissiveColor=texture2D(emissiveSampler,vEmissiveUV).rgb;\ngl_FragColor=vec4(emissiveColor,1.0);\n}";
|
|
|
+
|
|
|
/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
@@ -582,7 +585,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._isDirty = false;
|
|
|
this._render();
|
|
|
- this.update(false, this.premulAlpha);
|
|
|
+ this.update(true, this.premulAlpha);
|
|
|
};
|
|
|
AdvancedDynamicTexture.prototype._render = function () {
|
|
|
var textureSize = this.getSize();
|
|
@@ -5762,6 +5765,146 @@ var BABYLON;
|
|
|
})(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
|
|
|
})(BABYLON || (BABYLON = {}));
|
|
|
|
|
|
+/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
|
|
|
+
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ var GUI;
|
|
|
+ (function (GUI) {
|
|
|
+ /**
|
|
|
+ * Class used to render controls with fluent desgin
|
|
|
+ */
|
|
|
+ var FluentMaterial = /** @class */ (function (_super) {
|
|
|
+ __extends(FluentMaterial, _super);
|
|
|
+ function FluentMaterial(name, scene) {
|
|
|
+ return _super.call(this, name, scene) || this;
|
|
|
+ }
|
|
|
+ FluentMaterial.prototype.needAlphaBlending = function () {
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.needAlphaTesting = function () {
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.getAlphaTestTexture = function () {
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
|
|
+ if (this.isFrozen) {
|
|
|
+ if (this._wasPreviouslyReady && subMesh.effect) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var scene = this.getScene();
|
|
|
+ if (!this.checkReadyOnEveryCall && subMesh.effect) {
|
|
|
+ if (this._renderId === scene.getRenderId()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var engine = scene.getEngine();
|
|
|
+ scene.resetCachedMaterial();
|
|
|
+ //Attributes
|
|
|
+ var attribs = [BABYLON.VertexBuffer.PositionKind];
|
|
|
+ attribs.push(BABYLON.VertexBuffer.NormalKind);
|
|
|
+ attribs.push(BABYLON.VertexBuffer.UVKind);
|
|
|
+ var shaderName = "fluent";
|
|
|
+ var uniforms = ["world", "viewProjection", "emissiveMatrix"];
|
|
|
+ var samplers = ["emissiveSampler"];
|
|
|
+ var uniformBuffers = new Array();
|
|
|
+ BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
|
|
|
+ uniformsNames: uniforms,
|
|
|
+ uniformBuffersNames: uniformBuffers,
|
|
|
+ samplers: samplers,
|
|
|
+ defines: "",
|
|
|
+ maxSimultaneousLights: 4
|
|
|
+ });
|
|
|
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
|
+ attributes: attribs,
|
|
|
+ uniformsNames: uniforms,
|
|
|
+ uniformBuffersNames: uniformBuffers,
|
|
|
+ samplers: samplers,
|
|
|
+ defines: "",
|
|
|
+ fallbacks: null,
|
|
|
+ onCompiled: this.onCompiled,
|
|
|
+ onError: this.onError,
|
|
|
+ indexParameters: { maxSimultaneousLights: 4 }
|
|
|
+ }, engine));
|
|
|
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this._renderId = scene.getRenderId();
|
|
|
+ this._wasPreviouslyReady = true;
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
|
|
+ var scene = this.getScene();
|
|
|
+ var effect = subMesh.effect;
|
|
|
+ if (!effect) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._activeEffect = effect;
|
|
|
+ // Matrices
|
|
|
+ this.bindOnlyWorldMatrix(world);
|
|
|
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
|
+ if (this._mustRebind(scene, effect)) {
|
|
|
+ // Textures
|
|
|
+ if (this._emissiveTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
|
|
|
+ this._activeEffect.setTexture("emissiveSampler", this._emissiveTexture);
|
|
|
+ this._activeEffect.setMatrix("emissiveMatrix", this._emissiveTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._afterBind(mesh, this._activeEffect);
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.getActiveTextures = function () {
|
|
|
+ var activeTextures = _super.prototype.getActiveTextures.call(this);
|
|
|
+ if (this._emissiveTexture) {
|
|
|
+ activeTextures.push(this._emissiveTexture);
|
|
|
+ }
|
|
|
+ return activeTextures;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.hasTexture = function (texture) {
|
|
|
+ if (_super.prototype.hasTexture.call(this, texture)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (this._emissiveTexture === texture) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
|
|
|
+ if (this._emissiveTexture) {
|
|
|
+ this._emissiveTexture.dispose();
|
|
|
+ }
|
|
|
+ _super.prototype.dispose.call(this, forceDisposeEffect);
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.clone = function (name) {
|
|
|
+ var _this = this;
|
|
|
+ return BABYLON.SerializationHelper.Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.serialize = function () {
|
|
|
+ var serializationObject = BABYLON.SerializationHelper.Serialize(this);
|
|
|
+ serializationObject.customType = "BABYLON.GUI.FluentMaterial";
|
|
|
+ return serializationObject;
|
|
|
+ };
|
|
|
+ FluentMaterial.prototype.getClassName = function () {
|
|
|
+ return "FluentMaterial";
|
|
|
+ };
|
|
|
+ // Statics
|
|
|
+ FluentMaterial.Parse = function (source, scene, rootUrl) {
|
|
|
+ return BABYLON.SerializationHelper.Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
|
|
|
+ };
|
|
|
+ __decorate([
|
|
|
+ BABYLON.serializeAsTexture("emissiveTexture")
|
|
|
+ ], FluentMaterial.prototype, "_emissiveTexture", void 0);
|
|
|
+ __decorate([
|
|
|
+ BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
+ ], FluentMaterial.prototype, "emissiveTexture", void 0);
|
|
|
+ return FluentMaterial;
|
|
|
+ }(BABYLON.PushMaterial));
|
|
|
+ GUI.FluentMaterial = FluentMaterial;
|
|
|
+ })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
|
|
|
|
var BABYLON;
|
|
@@ -5974,6 +6117,7 @@ var BABYLON;
|
|
|
this._mesh = this._createMesh(scene);
|
|
|
this._mesh.isPickable = true;
|
|
|
this._mesh.metadata = this; // Store the control on the metadata field in order to get it when picking
|
|
|
+ this._affectMaterial(this._mesh);
|
|
|
}
|
|
|
return this._mesh;
|
|
|
};
|
|
@@ -5987,12 +6131,17 @@ var BABYLON;
|
|
|
// Do nothing by default
|
|
|
return null;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Affect a material to the given mesh
|
|
|
+ * @param mesh defines the mesh which will represent the control
|
|
|
+ */
|
|
|
+ Control3D.prototype._affectMaterial = function (mesh) {
|
|
|
+ mesh.material = null;
|
|
|
+ };
|
|
|
// Pointers
|
|
|
/** @hidden */
|
|
|
Control3D.prototype._onPointerMove = function (target, coordinates) {
|
|
|
- var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
|
|
|
- if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerMove(target, coordinates);
|
|
|
+ this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
|
|
|
};
|
|
|
/** @hidden */
|
|
|
Control3D.prototype._onPointerEnter = function (target) {
|
|
@@ -6000,9 +6149,7 @@ var BABYLON;
|
|
|
return false;
|
|
|
}
|
|
|
this._enterCount++;
|
|
|
- var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
|
|
|
- if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerEnter(target);
|
|
|
+ this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
|
|
|
if (this.pointerEnterAnimation) {
|
|
|
this.pointerEnterAnimation();
|
|
|
}
|
|
@@ -6011,9 +6158,7 @@ var BABYLON;
|
|
|
/** @hidden */
|
|
|
Control3D.prototype._onPointerOut = function (target) {
|
|
|
this._enterCount = 0;
|
|
|
- var canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
|
|
|
- if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerOut(target);
|
|
|
+ this.onPointerOutObservable.notifyObservers(this, -1, target, this);
|
|
|
if (this.pointerOutAnimation) {
|
|
|
this.pointerOutAnimation();
|
|
|
}
|
|
@@ -6025,9 +6170,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._downCount++;
|
|
|
this._downPointerIds[pointerId] = true;
|
|
|
- var canNotify = this.onPointerDownObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
- if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
|
|
|
+ this.onPointerDownObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
if (this.pointerDownAnimation) {
|
|
|
this.pointerDownAnimation();
|
|
|
}
|
|
@@ -6037,13 +6180,10 @@ var BABYLON;
|
|
|
Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
|
|
|
this._downCount = 0;
|
|
|
delete this._downPointerIds[pointerId];
|
|
|
- var canNotifyClick = notifyClick;
|
|
|
if (notifyClick && this._enterCount > 0) {
|
|
|
- canNotifyClick = this.onPointerClickObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
+ this.onPointerClickObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
}
|
|
|
- var canNotify = this.onPointerUpObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
- if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
|
|
|
+ this.onPointerUpObservable.notifyObservers(new GUI.Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
if (this.pointerUpAnimation) {
|
|
|
this.pointerUpAnimation();
|
|
|
}
|
|
@@ -6099,6 +6239,10 @@ var BABYLON;
|
|
|
this.onPointerOutObservable.clear();
|
|
|
this.onPointerUpObservable.clear();
|
|
|
this.onPointerClickObservable.clear();
|
|
|
+ if (this._mesh) {
|
|
|
+ this._mesh.dispose(false, true);
|
|
|
+ this._mesh = null;
|
|
|
+ }
|
|
|
// Behaviors
|
|
|
for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
|
|
|
var behavior = _a[_i];
|
|
@@ -6226,31 +6370,117 @@ var BABYLON;
|
|
|
if (!_this.mesh) {
|
|
|
return;
|
|
|
}
|
|
|
- _this.mesh.scaling.scaleInPlace(1.05);
|
|
|
+ _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
|
|
|
};
|
|
|
return _this;
|
|
|
}
|
|
|
+ Object.defineProperty(Button3D.prototype, "content", {
|
|
|
+ /**
|
|
|
+ * Gets or sets the GUI 2D content used to display the button's facade
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._content;
|
|
|
+ },
|
|
|
+ set: function (value) {
|
|
|
+ if (!this._host || !this._host.utilityLayer) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this._facadeTexture) {
|
|
|
+ this._facadeTexture = new BABYLON.GUI.AdvancedDynamicTexture("Facade", 512, 512, this._host.utilityLayer.utilityLayerScene, true, BABYLON.Texture.TRILINEAR_SAMPLINGMODE);
|
|
|
+ this._facadeTexture.rootContainer.scaleX = 2;
|
|
|
+ this._facadeTexture.rootContainer.scaleY = 2;
|
|
|
+ this._facadeTexture.premulAlpha = true;
|
|
|
+ }
|
|
|
+ this._facadeTexture.addControl(value);
|
|
|
+ this._currentMaterial.emissiveTexture = this._facadeTexture;
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
Button3D.prototype._getTypeName = function () {
|
|
|
return "Button3D";
|
|
|
};
|
|
|
// Mesh association
|
|
|
Button3D.prototype._createMesh = function (scene) {
|
|
|
+ var faceUV = new Array(6);
|
|
|
+ for (var i = 0; i < 6; i++) {
|
|
|
+ faceUV[i] = new BABYLON.Vector4(0, 0, 0, 0);
|
|
|
+ }
|
|
|
+ faceUV[1] = new BABYLON.Vector4(0, 0, 1, 1);
|
|
|
var mesh = BABYLON.MeshBuilder.CreateBox(this.name + "Mesh", {
|
|
|
width: 1.0,
|
|
|
height: 1.0,
|
|
|
- depth: 0.1
|
|
|
+ depth: 0.1,
|
|
|
+ faceUV: faceUV
|
|
|
}, scene);
|
|
|
- this._currentMaterial = new BABYLON.StandardMaterial(this.name + "Material", scene);
|
|
|
- this._currentMaterial.specularColor = BABYLON.Color3.Black();
|
|
|
- mesh.material = this._currentMaterial;
|
|
|
return mesh;
|
|
|
};
|
|
|
+ Button3D.prototype._affectMaterial = function (mesh) {
|
|
|
+ var material = new BABYLON.StandardMaterial(this.name + "Material", mesh.getScene());
|
|
|
+ material.specularColor = BABYLON.Color3.Black();
|
|
|
+ mesh.material = material;
|
|
|
+ this._currentMaterial = material;
|
|
|
+ };
|
|
|
return Button3D;
|
|
|
}(GUI.Control3D));
|
|
|
GUI.Button3D = Button3D;
|
|
|
})(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
|
|
|
})(BABYLON || (BABYLON = {}));
|
|
|
|
|
|
+/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ var GUI;
|
|
|
+ (function (GUI) {
|
|
|
+ /**
|
|
|
+ * Class used to create a button in 3D
|
|
|
+ */
|
|
|
+ var HolographicButton = /** @class */ (function (_super) {
|
|
|
+ __extends(HolographicButton, _super);
|
|
|
+ /**
|
|
|
+ * Creates a new button
|
|
|
+ * @param name defines the control name
|
|
|
+ */
|
|
|
+ function HolographicButton(name) {
|
|
|
+ var _this = _super.call(this, name) || this;
|
|
|
+ // Default animations
|
|
|
+ _this.pointerEnterAnimation = function () {
|
|
|
+ if (!_this.mesh) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _this.mesh.edgesRenderer.isEnabled = true;
|
|
|
+ };
|
|
|
+ _this.pointerOutAnimation = function () {
|
|
|
+ if (!_this.mesh) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _this.mesh.edgesRenderer.isEnabled = false;
|
|
|
+ };
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ HolographicButton.prototype._getTypeName = function () {
|
|
|
+ return "HolographicButton";
|
|
|
+ };
|
|
|
+ // Mesh association
|
|
|
+ HolographicButton.prototype._createMesh = function (scene) {
|
|
|
+ var mesh = _super.prototype._createMesh.call(this, scene);
|
|
|
+ mesh.edgesWidth = 0.5;
|
|
|
+ mesh.edgesColor = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
|
|
|
+ mesh.enableEdgesRendering();
|
|
|
+ mesh.edgesRenderer.isEnabled = false;
|
|
|
+ return mesh;
|
|
|
+ };
|
|
|
+ HolographicButton.prototype._affectMaterial = function (mesh) {
|
|
|
+ this._currentMaterial = new GUI.FluentMaterial(this.name + "Material", mesh.getScene());
|
|
|
+ mesh.material = this._currentMaterial;
|
|
|
+ };
|
|
|
+ return HolographicButton;
|
|
|
+ }(GUI.Button3D));
|
|
|
+ GUI.HolographicButton = HolographicButton;
|
|
|
+ })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
|
|
|
|
|
|
return BABYLON.GUI;
|