import { Vector4 } from "babylonjs/Maths/math.vector" ; import { TransformNode } from "babylonjs/Meshes/transformNode" ; import { AbstractMesh } from "babylonjs/Meshes/abstractMesh" ; import { CreateBox } from "babylonjs/Meshes/Builders/boxBuilder" ; import { Material } from "babylonjs/Materials/material" ; import { StandardMaterial } from "babylonjs/Materials/standardMaterial" ; import { Scene } from "babylonjs/scene" ; import { AbstractButton3D } from "./abstractButton3D" ; import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture" ; import { Color3 } from "babylonjs/Maths/math.color" ; /**
 * Class used to create a button in 3D
 */ export class Button3D extends AbstractButton3D { hidden protected _currentMaterial : Material ; param name constructor ( name ? ) { super ( name ) ; this . pointerEnterAnimation = ( ) => { if ( ! this . mesh ) { return ; } ( < StandardMaterial > this . _currentMaterial ) . emissiveColor = Color3 . Red ( ) ; } ; this . pointerOutAnimation = ( ) => { ( < StandardMaterial > this . _currentMaterial ) . emissiveColor = Color3 . Black ( ) ; } ; this . pointerDownAnimation = ( ) => { if ( ! this . mesh ) { return ; } this . mesh . scaling . scaleInPlace ( 0.95 ) ; } ; this . pointerUpAnimation = ( ) => { if ( ! this . mesh ) { return ; } this . mesh . scaling . scaleInPlace ( 1.0 / 0.95 ) ; } ; } param facadeTexture protected _applyFacade ( facadeTexture ) { ( < any > this . _currentMaterial ) . emissiveTexture = facadeTexture ; } protected _getTypeName ( ) { return "Button3D" ; } protected _createNode ( scene ) { var faceUV = new Array ( 6 ) ; for ( var i = 0 ; i < 6 ; i ++ ) { faceUV [ i ] = new Vector4 ( 0 , 0 , 0 , 0 ) ; } if ( scene . useRightHandedSystem ) { faceUV [ 0 ] . copyFromFloats ( 1 , 0 , 0 , 1 ) ; } else { faceUV [ 1 ] . copyFromFloats ( 0 , 0 , 1 , 1 ) ; } let mesh = CreateBox ( this . name + "_rootMesh" , { width : 1.0 , height : 1.0 , depth : 0.08 , faceUV : faceUV , wrap : true , } , scene ) ; return mesh ; } protected _affectMaterial ( mesh ) { let material = new StandardMaterial ( this . name + "Material" , mesh . getScene ( ) ) ; material . specularColor = Color3 . Black ( ) ; mesh . material = material ; this . _currentMaterial = material ; this . _resetContent ( ) ; } /**
     * Releases all associated resources
     */ public dispose ( ) { super . dispose ( ) ; this . _disposeFacadeTexture ( ) ; if ( this . _currentMaterial ) { this . _currentMaterial . dispose ( ) ; } } }