@@ -96,6 +96,11 @@ function set_orientation(value) {
96
96
if ( value == 'horizontal' ) {
97
97
ASPECT_RATIO = 16 / 9
98
98
}
99
+ if ( value == 'auto' ) {
100
+ var width = window . innerWidth
101
+ var height = window . innerHeight
102
+ ASPECT_RATIO = width / height
103
+ }
99
104
set_aspect_ratio ( ASPECT_RATIO )
100
105
}
101
106
@@ -304,7 +309,7 @@ curves = {
304
309
305
310
ASSETS_FOLDER = ''
306
311
TAPTAPIR_TEXTURES = { }
307
- entities = [ ]
312
+ ENTITIES = [ ]
308
313
AUTOPARENT_TO_SCENE = true
309
314
LAST_SCENE = null
310
315
DEFAULT_FONT = null
@@ -321,7 +326,7 @@ class Entity {
321
326
}
322
327
if ( ! this . add_to_scene ) {
323
328
this . el = document . createElement ( options [ 'type' ] )
324
- entities . push ( this )
329
+ ENTITIES . push ( this )
325
330
for ( const [ key , value ] of Object . entries ( options ) ) {
326
331
this [ key ] = value
327
332
}
@@ -343,13 +348,13 @@ class Entity {
343
348
this . el . style . backgroundColor = 'rgba(0,0,0,0)'
344
349
// this.el.style.pointerEvents = 'none'
345
350
this . model = document . createElement ( options [ 'type' ] )
346
- this . model . entity_index = entities . length
351
+ this . model . entity_index = ENTITIES . length
347
352
this . model . id = 'model'
348
353
this . el . appendChild ( this . model )
349
354
350
355
this . model . className = options [ 'type' ]
351
356
this . model . style . opacity = 1
352
- entities . push ( this )
357
+ ENTITIES . push ( this )
353
358
354
359
this . setTimeout_calls = { }
355
360
if ( ! ( 'render' in options ) || options [ 'render' ] ) {
@@ -1096,13 +1101,14 @@ class StateHandler {
1096
1101
else {
1097
1102
this . hard_state = value
1098
1103
}
1104
+ this . _state = value
1099
1105
}
1100
1106
set hard_state ( value ) { // set the state without fading
1101
1107
// print('set state to:', value)
1102
1108
if ( this . _state === value ) {
1103
1109
return
1104
1110
}
1105
- for ( let entity of this . states ) {
1111
+ for ( let entity of this . states . values ( ) ) {
1106
1112
if ( value === entity || value === entity . name ) {
1107
1113
entity . enabled = true
1108
1114
if ( entity . on_enter ) {
@@ -1279,7 +1285,7 @@ time_of_press = 0
1279
1285
function _handle_mouse_click ( e ) {
1280
1286
// mouse.left = true
1281
1287
element_hit = document . elementFromPoint ( e . pageX - window . pageXOffset , e . pageY - window . pageYOffset ) ;
1282
- entity = entities [ element_hit . entity_index ]
1288
+ entity = ENTITIES [ element_hit . entity_index ]
1283
1289
// print(element_hit, entity.on_click)
1284
1290
if ( ! element_hit || entity === undefined || entity . on_click === undefined ) {
1285
1291
mouse . swipe_start_position = mouse . position
@@ -1368,14 +1374,14 @@ function _onmousemove(pageX, pageY, clientX, clientY, pressure, target) {
1368
1374
// print(mouse.point)
1369
1375
}
1370
1376
element_hit = document . elementFromPoint ( pageX - window . scrollX , pageY - window . scrollY ) ;
1371
- _entity = entities [ element_hit . entity_index ]
1377
+ _entity = ENTITIES [ element_hit . entity_index ]
1372
1378
if ( _entity ) {
1373
1379
mouse . hovered_entity = _entity
1374
1380
}
1375
1381
else {
1376
1382
mouse . hovered_entity = null
1377
1383
}
1378
- for ( var e of entities ) {
1384
+ for ( var e of ENTITIES ) {
1379
1385
if ( e . dragging ) {
1380
1386
if ( ! e . lock_x ) {
1381
1387
// print(mouse.x, e.start_offset[0])
@@ -1616,7 +1622,7 @@ function _step(_timestamp) {
1616
1622
update ( )
1617
1623
}
1618
1624
1619
- for ( var e of entities ) {
1625
+ for ( var e of ENTITIES ) {
1620
1626
if ( e . update && e . enabled ) {
1621
1627
e . update ( )
1622
1628
}
@@ -1671,7 +1677,7 @@ function _input(event) {
1671
1677
1672
1678
if ( key == 'left mouse up' ) {
1673
1679
// drop draggables
1674
- for ( var e of entities ) {
1680
+ for ( var e of ENTITIES ) {
1675
1681
if ( e . dragging ) {
1676
1682
e . dragging = false
1677
1683
if ( e . drop ) {
@@ -1681,7 +1687,7 @@ function _input(event) {
1681
1687
}
1682
1688
}
1683
1689
1684
- for ( var e of entities ) {
1690
+ for ( var e of ENTITIES ) {
1685
1691
if ( e . input && e . enabled ) {
1686
1692
e . input ( key )
1687
1693
}
0 commit comments