How to use the babylonjs.Color3 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 wanadev / holes-in / debug / js / debugger3d.js View on Github external
createScene(engine,canvas) {
      const camera = new BABYLON.ArcRotateCamera("camera1",0, 0, 200,new BABYLON.Vector3(0,0,0), debugger3d.scene);
      camera.radius = 200;
      camera.setTarget(new BABYLON.Vector3(0,0,0));
      camera.attachControl(canvas, false);
      debugger3d.camera= camera;

      var light1 = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(1,1,1), debugger3d.scene);
      var light2 = new BABYLON.HemisphericLight('light2', new BABYLON.Vector3(-1,-1,0), debugger3d.scene);

      light1.diffuse = new BABYLON.Color3(1, 1, 1);
      light1.specular = new BABYLON.Color3(1, 1, 1);

      light2.diffuse = new BABYLON.Color3(1, 1, 1);
      light2.specular = new BABYLON.Color3(1, 1, 1);

      debugger3d.scene.clearColor = new BABYLON.Color3(0.3,0.3,0.3);

      debugger3d.scene.onPointerDown = function (evt, pickResult) {
        // if the click hits the ground object, we change the impact position
        var textureCoordinates = pickResult.getTextureCoordinates();
        console.log("tex ", textureCoordinates, " point ", pickResult.pickedPoint);
    };

  },
github rodrigo-brito / gocity / ui / src / App.js View on Github external
initScene() {
    this.scene.clearColor = new BABYLON.Color3(0.1, 0.1, 0.1);
    this.scene.ambientColor = new BABYLON.Color3(0.1, 0.1, 0.1);
    // This creates and positions a free camera (non-mesh)
    this.camera = new BABYLON.ArcRotateCamera(
      "camera",
      0,
      0,
      10,
      BABYLON.Vector3.Zero(),
      this.scene
    );

    // This targets the camera to scene origin
    this.camera.setTarget(BABYLON.Vector3.Zero());

    // This attaches the camera to the canvas
    this.camera.attachControl(this.canvas, true);
github rodrigo-brito / gocity / ui / src / App.js View on Github external
initScene() {
    this.scene.clearColor = new BABYLON.Color3(0.1, 0.1, 0.1);
    this.scene.ambientColor = new BABYLON.Color3(0.1, 0.1, 0.1);
    // This creates and positions a free camera (non-mesh)
    this.camera = new BABYLON.ArcRotateCamera(
      "camera",
      0,
      0,
      10,
      BABYLON.Vector3.Zero(),
      this.scene
    );

    // This targets the camera to scene origin
    this.camera.setTarget(BABYLON.Vector3.Zero());

    // This attaches the camera to the canvas
    this.camera.attachControl(this.canvas, true);
github mpwassler / 3dproductview / src / Components / Scene3d.js View on Github external
ArcRotateCamera,
  Vector3,
  HemisphericLight,
  Mesh,
  Color3,
  Tools,
  MeshBuilder,
  Texture,
  StandardMaterial,
  Axis
} from 'babylonjs'
// Here we extend Reacts component class 
class Scene3d extends Component {

  colors = {
    red : new Color3(0.5137, 0, 0),
    blue :  new Color3(0, 0, 0.5137),
    green : new Color3(0, 0.5137, 0),
    yellow : new Color3(0.5137, 0.5137, 0),
    black : new Color3(0, 0, 0),
    white : new Color3(1, 1, 1),
    grey : new Color3(0.5, 0.5, 0.5),
  }
  /*
  * We add an object which contains a hash table
  * of our regions. These nested objects 
  * contain the coordinates we will move 
  * the camera to if there key is 
  * selected. As well as an id 
  * to select individual meshs
  */
  regions = {
github rodrigo-brito / gocity / src / App.js View on Github external
children.forEach(data => {
      var color = getProportionalColor(
        colors[data.type].start,
        colors[data.type].end,
        Math.min(100, data.numberOfLines / 2000.0)
      );

      var mesh = this.addBlock({
        x: data.position.x,
        y: data.position.y,
        width: data.width,
        depth: data.depth,
        height: data.numberOfMethods,
        color: new BABYLON.Color3(color.r / 255, color.g / 255, color.b / 255),
        parent: parent,
        info: {
          name: data.name,
          url: data.url,
          type: data.type,
          NOM: data.numberOfMethods,
          NOL: data.numberOfLines,
          NOA: data.numberOfAttributes
        }
      });

      if (parent) {
        mesh.parent = parent;
      }

      if (data.children && data.children.length > 0) {
github brochington / Akkad / src / classes / MeshManager.js View on Github external
outlineColor(mesh, color) {
        mesh.outlineColor = new Babylon.Color3(...color);
    }
};
github brochington / Akkad / src / components / lights / HemisphericLight.js View on Github external
render() {
        const {diffuse, specular, children} = this.props;

        const renderDiffuse = diffuse && (
            
        );

        const renderSpecular = specular && (
            
        );

        return (
            
                
                
                    {renderDiffuse}
                    {renderSpecular}
                    {children}
                
            
        );
github chad-autry / hex-grid-map-3D / src / meshFactories / ArrowMeshFactory.js View on Github external
babylon.Mesh.CAP_END,
      scene
    );

    //Color the center
    var arrowCenterMaterial = new babylon.StandardMaterial(
      "arrowCenterMaterial",
      scene
    );
    rgb = this.hexToRgb(item.fillColor);
    arrowCenterMaterial.diffuseColor = new babylon.Color3(
      rgb.r / 256,
      rgb.g / 256,
      rgb.b / 256
    );
    arrowCenterMaterial.specularColor = new babylon.Color3(
      rgb.r / 256,
      rgb.g / 256,
      rgb.b / 256
    );
    arrowCenterMaterial.emissiveColor = new babylon.Color3(
      rgb.r / 256,
      rgb.g / 256,
      rgb.b / 256
    );
    extrudedCenter1.material = extrudedCenter1.materia = arrowCenterMaterial;

    arrow = babylon.Mesh.MergeMeshes([arrow, extrudedCenter1, extrudedCenter2]);
  }

  //Scale the whole arror
  arrow.scaling.x = item.scaleLength;
github mishig25 / 3d-posenet / graphics.js View on Github external
initScene(){
        this.scene = new BABYLON.Scene(this.engine);
        this.scene.clearColor = new BABYLON.Color3(0.5, 0.8, 0.5);
        const camera = this.setCamera();
        const sphere = BABYLON.MeshBuilder.CreateSphere('', { diameter: .0001 }, this.scene);
        BABYLON.SceneLoader.ImportMesh("", `/${process.env.BPATH}/Scenes/Dude/`, "Dude.babylon", this.scene, (newMeshes, particleSystems, skeletons) => {
            const mesh = newMeshes[0];
            const skeleton = skeletons[0];
            mesh.scaling = new BABYLON.Vector3(0.1, 0.1, 0.1);
            mesh.position = new BABYLON.Vector3(0, 0, 0);

            const head_bone = skeleton.bones[7];
            const right_shoulder_bone = skeleton.bones[13];
            const right_arm_bone = skeleton.bones[14];
            const left_shoulder_bone = skeleton.bones[32];
            const left_arm_bone = skeleton.bones[33];

            const lookAtCtl = new BABYLON.BoneLookController(mesh, head_bone, sphere.position, { adjustYaw: Math.PI * .5, adjustRoll: Math.PI * .5 });