How to use the babylonjs.Color4 function in babylonjs

To help you get started, we’ve selected a few babylonjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ltackett / musictocodeto / src / Components / CLI / CLI.tsx View on Github external
const onSceneMount = async (e: SceneEventArgs) => {
    scene = e.scene
    engine = e.engine
    canvas = e.canvas

    scene.clearColor = new BABYLON.Color4(0, 0, 0, 2)

    // This creates and positions a free camera (non-mesh)
    const camera = new BABYLON.ArcRotateCamera(
      "camera1",
      -Math.PI / 2,
      Math.PI / 2,
      3000,
      new BABYLON.Vector3(0, 0, 0),
      scene
    );

    camera.maxZ = 20000

    // This targets the camera to scene origin
    camera.setTarget(BABYLON.Vector3.Zero());
github brianzinn / create-react-app-babylonjs / src / with2DUI.js View on Github external
constructor() {
    super();
    
    this.state = {
      plane: undefined,
      showModal: false,
      clickMeshName: undefined,
      allowedMeshes: [
        'red box',
        'blue box',
        'green box'
      ],
      sceneClearColor: new Color4(0.5, 0.5, 0.5, 0.5)
    }

    this.meshPicked = this.meshPicked.bind(this);
    this.setPlane = this.setPlane.bind(this);
    // TODO: fix that bind() is needed on assignment on button pointerDown handlers
  }
github prateekbh / hopon / game / Platform.js View on Github external
createBox() {
    const box = MeshBuilder.CreateBox(
      'box1',
      {
        size: 2,
        height: 0.2,
        faceColors: Color4(0.16, 0.36, 0.26, 1)
      },
      this._scene
    );
    const boxMaterial = new StandardMaterial('boxMaterial', this._scene);
    box.checkCollisions = true;
    // add Physics properties to this box
    box.physicsImpostor = new PhysicsImpostor(
      box,
      PhysicsImpostor.BoxImpostor,
      { mass: 0, restitution: 0 },
      this._scene
    );
    box.material = boxMaterial;
    box.material.alpha = 0;
    boxMaterial.diffuseColor = Platform.colors[0];
    this.addDroppingEffect(box);
github springtype-org / springtype / e2e / babylon-3d / src / component / first-scene / first-scene.tsx View on Github external
private createScene() {
        this.scene = new Scene(this.engine);
        this.scene.clearColor = new Color4(0, 0, 0, 0);
    }
github springtype-org / springtype / src / packages / cli / springtype / template / project / babylon-3d / src / component / first-scene / first-scene.tsx View on Github external
private createScene() {
        this.scene = new Scene(this.engine);
        this.scene.clearColor = new Color4(0, 0, 0, 0);
    }
github brianzinn / create-react-app-babylonjs / src / with2DUI.js View on Github external
this.setState((state) => ({
        ...state,
        showModal: false,
        plane: undefined,
        sceneClearColor: new Color4(0.5, 0.5, 0.5, 0.5)
      }));
    });
github brianzinn / create-react-app-babylonjs / src / with2DUI.js View on Github external
meshPicked(mesh) {
    if (this.state.allowedMeshes.indexOf(mesh.name) !== -1) {
      const clickedMeshName = mesh.name
      let clickedMeshColor;
      let sceneClearColor;
      switch(clickedMeshName) {
        case 'red box':
          clickedMeshColor = Color3.Red().toHexString()
          sceneClearColor = new Color4(1, 0, 0, 0.5)
          break;
        case 'blue box':
          clickedMeshColor = Color3.Blue().toHexString()
          sceneClearColor = new Color4(0, 0, 1, 0.5)
          break;
        case 'green box':
        default:
          clickedMeshColor = Color3.Green().toHexString()
          sceneClearColor = new Color4(0, 1, 0, 0.5)
          break;
      }

      this.setState((state) => ({
        ...state,
        showModal: true,
        clickedMeshName,
        clickedMeshColor,
        sceneClearColor
      }))
    } else {