working principle

chemistry_example
Fabien Benetou 2 years ago
parent cdb241ac8f
commit 15a385a0a3
  1. 42
      index.html

@ -2091,6 +2091,31 @@ function addCompoundPrimitiveExample(position="0 1.4 -0.2"){
return el
}
function collideTwoElements(elementA, elementB, compatible=true){ // dropping b on a
let a = elementA.object3D.position
let b = elementB.object3D.position
// should rely on starting position otherwise it will be too small
// tested without hand tracking so a "jump" from source to target
let dir = new THREE.Vector3()
let vol = new THREE.Box3
dir.subVectors( a, b ).normalize()
if (!compatible){
elementB.object3D.position.add( dir.multiplyScalar(-1)) // repulsive
} else {
elementB.object3D.position.copy( a )
vol.setFromObject( elA.object3D )
elementB.object3D.position.x += (vol.max.x - vol.min.x) // snapping equivalent
// then can also test for larger structures
// e.g H2O chain "../content/WaterBottle.glb" // by sirkitree (CC-BY)
}
}
/* testing
elA = addBlockCodeExample('O', '-0.2 1.4 -0.2')
elB = addBlockCodeExample('H') // need few milliseconds to create before testing, so no copy/paste
collideTwoElements(elA, elB)
collideTwoElements(elA, elB, false)
*/
function addBlockCodeExample(text="hi", pos="0 1.4 -0.2", color="black", outlineColor="white"){
let el = addNewNote( text )
el.setAttribute("color", color)
@ -2286,20 +2311,11 @@ consider pick then apply, i.e changeColorLastId() but for next Id
<a-sky hide-on-enter-ar color="white"></a-sky>
<a-entity hide-on-enter-ar="" id="environment" class="hidableenvironment" gltf-model="../content/SourceCityToolkit/AR_Market.glb" scale="1 1 1" position="17 -10 -4" rotation="0 0 0"></a-entity>
<a-entity hide-on-enter-ar="" id="environmentsky" class="hidableenvironment" gltf-model="../content/SourceCityToolkit/SKY_Market_day.glb" scale="1 1 1" position="17 -10 -4" rotation="0 0 0"></a-entity>
<a-text target value="instructions : \n--right pinch to move\n--left pinch to execute" position="0 1.65 -0.2" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr addBlockCodeExample()" position="0 1.65 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr addAllPrimitives()" position="0 1.60 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr addCompoundPrimitiveExample()" position="0 1.55 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr rescalePlace(1/10, 1)" position="0 1.50 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr rescalePlace()" position="0 1.45 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr tile_snapping_enabled = !tile_snapping_enabled" position="0 1.40 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="getfromid_color" value="jxr changeColorLastId()" position="0 1.35 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="getfromid_id" value="jxr getIdFromPick()" position="0 1.30 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="instructions : \n--right pinch to move\n--left pinch to execute\n\nTry to make a water molecule" position="0 1.65 -0.2" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr addBlockCodeExample('H')" position="0 1.65 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr addBlockCodeExample('O', '-0,5 1.4 -0.2')" position="0 1.60 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="locationreload" value="jxr location.reload()" position="0 1.20 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="getfromclass_color" value="jxr changeColorLastClass()" position="0 1.15 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="getfromclass_id" value="jxr getClassFromPick()" position="0 1.10 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target id="changeColorNextPinch" value="jxr changeColorNextPinch()" position="0 1.05 -0.1" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr pushLeftClass('tiles')" position=" -0.2 1.55 0.1" rotation="0 90 0" scale="0.1 0.1 0.1"></a-text>
<a-text target value="jxr pushRightClass('tiles')" position=" -0.2 1.50 0.1" rotation="0 90 0" scale="0.1 0.1 0.1"></a-text>

Loading…
Cancel
Save