1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /// <reference path="../../../dist/preview release/babylon.d.ts"/>
- module BABYLON {
- export class BrickProceduralTexture extends ProceduralTexture {
- private _numberOfBricksHeight: number = 15;
- private _numberOfBricksWidth: number = 5;
- private _jointColor = new Color3(0.72, 0.72, 0.72);
- private _brickColor = new Color3(0.77, 0.47, 0.40);
- constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
- super(name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps);
- this.updateShaderUniforms();
- }
- public updateShaderUniforms() {
- this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
- this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
- this.setColor3("brickColor", this._brickColor);
- this.setColor3("jointColor", this._jointColor);
- }
- @serialize()
- public get numberOfBricksHeight(): number {
- return this._numberOfBricksHeight;
- }
- public set numberOfBricksHeight(value: number) {
- this._numberOfBricksHeight = value;
- this.updateShaderUniforms();
- }
- @serialize()
- public get numberOfBricksWidth(): number {
- return this._numberOfBricksWidth;
- }
- public set numberOfBricksWidth(value: number) {
- this._numberOfBricksWidth = value;
- this.updateShaderUniforms();
- }
- @serializeAsColor3()
- public get jointColor(): Color3 {
- return this._jointColor;
- }
- public set jointColor(value: Color3) {
- this._jointColor = value;
- this.updateShaderUniforms();
- }
- @serializeAsColor3()
- public get brickColor(): Color3 {
- return this._brickColor;
- }
- public set brickColor(value: Color3) {
- this._brickColor = value;
- this.updateShaderUniforms();
- }
- /**
- * Serializes this brick procedural texture
- * @returns a serialized brick procedural texture object
- */
- public serialize(): any {
- var serializationObject = SerializationHelper.Serialize(this, super.serialize());
- serializationObject.customType = "BABYLON.BrickProceduralTexture";
- return serializationObject;
- }
- /**
- * Creates a Brick Procedural Texture from parsed brick procedural texture data
- * @param parsedTexture defines parsed texture data
- * @param scene defines the current scene
- * @param rootUrl defines the root URL containing brick procedural texture information
- * @returns a parsed Brick Procedural Texture
- */
- public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BrickProceduralTexture {
- var texture = SerializationHelper.Parse(() => new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
- return texture;
- }
- }
- }
|