Changeset 1326 for js/standard_expdef_demo/js/world
- Timestamp:
- 08/25/24 01:56:48 (11 months ago)
- Location:
- js/standard_expdef_demo/js/world
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
js/standard_expdef_demo/js/world/core.js
r880 r1326 17 17 this.sky = this.Sky(); 18 18 this.sun = this.Sun(); 19 this.table = this.Table();20 19 } 21 20 … … 25 24 texture.repeat.set(Config.Ground.REPEAT, Config.Ground.REPEAT); 26 25 texture.anisotropy = Config.Ground.ANISOTROPY; 26 texture.colorSpace = THREE.SRGBColorSpace; 27 27 28 let geometry = new THREE.Plane BufferGeometry(Config.Ground.WIDTH, Config.Ground.WIDTH);28 let geometry = new THREE.PlaneGeometry(Config.Ground.WIDTH, Config.Ground.WIDTH); 29 29 let material = new THREE.MeshLambertMaterial({map: texture}); 30 30 let ground = new THREE.Mesh(geometry, material); … … 36 36 } 37 37 38 Table() { 39 let table = new Table(Config.Simulation.GENOTYPES); 38 createTable(genotypes,genotypeEncoding){ 39 this.table = this.Table(genotypes,genotypeEncoding); 40 } 41 42 setGenotypes(genotypes, genotypeEncoding){ 43 this.table.genotypes = genotypes; 44 for (let i = 0; i < this.table.genotypes.length; i++) { 45 this.scene.remove(this.table.genotypePlanks[i].textMesh); 46 // this.table.genotypePlanks[i] = new GenotypePlank(genotypes[i],genotypeEncoding,i); 47 this.table.genotypePlanks[i].updateGenotype(genotypes[i],genotypeEncoding); 48 this.scene.add(this.table.genotypePlanks[i].textMesh); 49 this.table.fitnessPlanks[i].updateFitness((Math.random() * 100).toFixed(2)); 50 } 51 } 52 53 Table(genotypes,genotypeEncoding) { 54 let table = new Table(genotypes,genotypeEncoding); 40 55 this.scene.add(table.board); 41 56 this.scene.add(table.genotypeHeader.mesh); … … 76 91 77 92 Sky() { 78 let sky = new THREE.Sky()93 let sky = new Sky() 79 94 sky.scale.setScalar(Config.Sky.SCALE); 80 95 sky.material.uniforms.turbidity.value = Config.Sky.TURBIDITY; 81 96 sky.material.uniforms.rayleigh.value = Config.Sky.RAYLEIGH; 82 97 // sky.material.uniforms.luminance.value = Config.Sky.LUMINANCE; 83 98 sky.material.uniforms.mieCoefficient.value = Config.Sky.MIE_COEFFICIENT; 84 99 sky.material.uniforms.mieDirectionalG.value = Config.Sky.MIE_DIRECTIONAL_G; … … 89 104 Sun() { 90 105 let sun = new THREE.Mesh( 91 new THREE.Sphere BufferGeometry(Config.Sun.RADIUS, Config.Sun.WIDTH_SEGMENTS, Config.Sun.HEIGHT_SEGMENTS),106 new THREE.SphereGeometry(Config.Sun.RADIUS, Config.Sun.WIDTH_SEGMENTS, Config.Sun.HEIGHT_SEGMENTS), 92 107 new THREE.MeshBasicMaterial({color: Config.Sun.COLOR}) 93 108 ); -
js/standard_expdef_demo/js/world/object/arrow.js
r880 r1326 22 22 let material = new THREE.MeshLambertMaterial({map: texture}); 23 23 material.opacity = 0; 24 material.blending = THREE.NoBlending;24 // material.blending = THREE.NoBlending; 25 25 26 26 this.mesh = new THREE.Mesh(geometry, material); -
js/standard_expdef_demo/js/world/object/framstick.js
r880 r1326 112 112 } 113 113 114 let model = new Module.Model(genoObj, true); 114 let model = new Module.Model(genoObj, Module.Model["SHAPETYPE_UNKNOWN"], true); 115 model.open(); 116 model.close(); 115 117 Module.destroy(stringObj); 116 118 Module.destroy(genoObj); -
js/standard_expdef_demo/js/world/object/table.js
r880 r1326 10 10 */ 11 11 12 constructor(genotypes) { 13 this.genotypes = genotypes 12 constructor(genotypes,genotypeType) { 13 this.genotypes = genotypes; 14 this.genotypeType = genotypeType; 14 15 15 16 this.board = this.Board(); … … 25 26 texture.repeat.set(Config.Table.Board.REPEAT, Config.Table.Board.REPEAT); 26 27 texture.anisotropy = Config.Table.Board.ANISOTROPY; 28 texture.colorSpace = THREE.SRGBColorSpace; 27 29 28 30 let geometry = new THREE.BoxGeometry(Config.Table.Board.WIDTH, … … 32 34 let material = new THREE.MeshLambertMaterial({map: texture}); 33 35 material.opacity = 0; 34 material.blending = THREE.NoBlending;36 // material.blending = THREE.NoBlending; 35 37 36 38 let board = new THREE.Mesh(geometry, material); … … 46 48 let planks = [] 47 49 for (let i = 0; i < this.genotypes.length; i++) { 48 planks.push(new GenotypePlank(this.genotypes[i], i));50 planks.push(new GenotypePlank(this.genotypes[i],this.genotypeType, i)); 49 51 } 50 52 return planks … … 60 62 61 63 GenotypeHeader() { 62 return new GenotypePlank("Genotype", this.genotypes.length, true)64 return new GenotypePlank("Genotype",this.genotypeType, this.genotypes.length, true) 63 65 } 64 66 … … 71 73 class GenotypePlank { 72 74 73 constructor(genotype, position, bold) {75 constructor(genotype, genotypeEncoding, position, bold) { 74 76 this.genotype = genotype; 75 77 this.position = { … … 83 85 texture.repeat.set(Config.Table.GenotypePlank.REPEAT, Config.Table.GenotypePlank.REPEAT); 84 86 texture.anisotropy = Config.Table.GenotypePlank.ANISOTROPY; 87 texture.colorSpace = THREE.SRGBColorSpace; 85 88 86 89 let geometry = new THREE.BoxGeometry(Config.Table.GenotypePlank.WIDTH, … … 94 97 this.mesh.receiveShadow = Config.Table.GenotypePlank.RECEIVE_SHADOW; 95 98 96 this.textMesh = Text.getGenotypeMesh(this.genotype.replace("/*4*/ ", "")); 99 this.genotypeType = genotypeEncoding; 100 this.textMesh = Text.getGenotypeMesh(this.genotype,this.genotypeType); 97 101 if (bold == true) { 98 this.textMesh = Text.getFitnessMesh(this.genotype.replace( "/*4*/ ", ""));102 this.textMesh = Text.getFitnessMesh(this.genotype.replace(`${this.genotypeType} `, "")); 99 103 } 100 104 this.textMesh.position.set(this.position.x, this.position.y, this.position.z + 1); 105 } 106 107 updateGenotype(genotype,genotypeType){ 108 this.genotype = genotype; 109 this.genotypeType = genotypeType; 110 this.textMesh = Text.getGenotypeMesh(this.genotype,this.genotypeType); 111 this.textMesh.position.set(this.position.x, this.position.y, this.position.z + 1); 101 112 } 102 113 … … 137 148 texture.repeat.set(Config.Table.FitnessPlank.REPEAT, Config.Table.FitnessPlank.REPEAT); 138 149 texture.anisotropy = Config.Table.FitnessPlank.ANISOTROPY; 150 texture.colorSpace = THREE.SRGBColorSpace; 139 151 140 152 let geometry = new THREE.BoxGeometry(Config.Table.FitnessPlank.WIDTH, … … 150 162 this.textMesh = Text.getFitnessMesh(this.fitness); 151 163 this.textMesh.position.set(this.position.x, this.position.y, this.position.z + 1); 164 } 165 166 updateFitness(value){ 167 this.fitness = value; 168 this.textMesh.element.innerHTML = roundNumber(this.fitness,2); 152 169 } 153 170 -
js/standard_expdef_demo/js/world/object/text.js
r880 r1326 6 6 7 7 var Text = { 8 getGenotypeMesh: function(genotype) { 8 styleRegex: /<style>.*<\/style>/, 9 numberRegex : /-?\d+(\.\d+)?/g, 10 roundMatch: function(match) { 11 return roundNumber(match,2).toString(); 12 }, 13 14 getGenotypeMesh: function(genotype,genotypeType) { 15 const genman = new Module.GenMan(); 16 genotype = genotype.replace(this.numberRegex, this.roundMatch); 17 genotype = genotype.replaceAll("\n","⤶"); 9 18 if (genotype.length > 20) { 10 genotype = genotype.slice(0, 20) + "..."19 genotype = genotype.slice(0,30) + "..." 11 20 } 12 21 var element = document.createElement("div"); 13 element.className = "genotype"; 14 element.textContent = genotype; 15 return new THREE.CSS3DObject(element); 22 element.innerHTML = genman.HTMLize(genotype).c_str(); 23 element.innerHTML = element.innerHTML.replace(this.styleRegex,"").replace(genotypeType,""); 24 Module.destroy(genman); 25 return new CSS3DObject(element); 16 26 }, 17 27 … … 20 30 element.className = "fitness"; 21 31 element.textContent = fitness; 22 return new THREE.CSS3DObject(element);32 return new CSS3DObject(element); 23 33 }, 24 34 … … 27 37 element.className = "info"; 28 38 element.textContent = info; 29 return new THREE.CSS3DObject(element);39 return new CSS3DObject(element); 30 40 } 31 41 }
Note: See TracChangeset
for help on using the changeset viewer.