initMaterial method

dynamic initMaterial()

Implementation

initMaterial() async {
 // var material;
  var textureLoader = new THREE.TextureLoader();


  /*if (! !material) {
    return material;
  }*/

  // TODO
  // Canvas2D で noise 画像を作る
 // print("xxx"+VolumetricFire.texturePath);
  if (nzw==null) {
    nzw = await textureLoader.loadAsync(VolumetricFire.texturePath + 'nzw.png');
    nzw?.wrapS = THREE.RepeatWrapping;
    nzw?.wrapT = THREE.RepeatWrapping;
    nzw?.magFilter = THREE.LinearFilter;
    nzw?.minFilter = THREE.LinearFilter;
  }

  if (fireProfile==null) {
    fireProfile = await textureLoader.loadAsync(
        VolumetricFire.texturePath + 'firetex.png');
    fireProfile?.wrapS = THREE.ClampToEdgeWrapping;
    fireProfile?.wrapT = THREE.ClampToEdgeWrapping;
    fireProfile?.magFilter = THREE.LinearFilter;
    fireProfile?.minFilter = THREE.LinearFilter;
  }

  var uniforms = {
    'nzw': {
      'type': 't',
      'value': nzw
    },
    'fireProfile': {
      'type': 't',
      'value': fireProfile
    },
    'time': {
      'type': 'f',
      'value': 1.0
    },
    'flamingcolor': {
      'value': _color //THREE.Vector3(0.1,0.1,1.0)
    }
  };

 // THREE.Material dog;

  THREE.RawShaderMaterial material = new THREE.RawShaderMaterial({
    'vertexShader': vs,
    'fragmentShader': fs,
    'uniforms': uniforms,
    'side': THREE.DoubleSide,
    'blending': THREE.AdditiveBlending,
    'transparent': true
  });

  //print("uuu"+ material.visible.toString());
  return material;
}