Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegerSequencer intervals #2

Closed
andreasplesch opened this issue Oct 5, 2017 · 3 comments
Closed

IntegerSequencer intervals #2

andreasplesch opened this issue Oct 5, 2017 · 3 comments

Comments

@andreasplesch
Copy link

andreasplesch commented Oct 5, 2017

This test scene:

http://x3dom-sequencer-interval-test.glitch.me/IntegerKeyTest.x3d

has sequence keys=0,0.5,1 and keyValues=0,1,2

Most x3d browsers show this result:
key < 0: value is 0
key = 0: value is 0
key = 0.25: value is 0
key = 0.5: value is 1
key = 1: value is 2
key > 1: value is 2

However, view3dscene shows this result:
key < 0: value is 0
key = 0: value is 0
key = 0.25: value is 0
key = 0.5: value is 0
key = 1: value is 2
key > 1: value is 2

For key = 0.5 the second interval [0.5,1) should be selected giving a keyValue of 1 since 0.5 is part of this interval. 0.5 is excluded from the first interval [0,0.5).

It could be a floating point comparison issue.
This is probably more a castle-engine issue.

@andreasplesch
Copy link
Author

The test scene:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Interactive' version='3.3'  xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.3.xsd '>
  <Scene>    
      <NavigationInfo></NavigationInfo>
      <IntegerSequencer DEF='ChooserLT0' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <IntegerSequencer DEF='Chooser0' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <IntegerSequencer DEF='Chooser025' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <IntegerSequencer DEF='Chooser05' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <IntegerSequencer DEF='Chooser1' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <IntegerSequencer DEF='ChooserGT1' key='0 0.5 1' keyValue='0 1 2' containerField='children' ></IntegerSequencer>
      <Transform translation='0 3 0'>
        <Shape>
          <Text string='"keys 0,0.5,1 : values 0,1,2"' >
            <FontStyle justify='"MIDDLE" "END"'></FontStyle>
          </Text>
          <Appearance DEF='titleColor'>
            <Material diffuseColor='0.5 0.5 0.7' ></Material>
          </Appearance>
        </Shape>
    </Transform>
    <Transform translation='-1 2 0'>
        <Shape>
          <Text string='"key &lt; 0:"' >
            <FontStyle DEF='right' justify='"END" "END"'></FontStyle>
          </Text>
          <Appearance DEF='keyColor'>
            <Material diffuseColor='0.5 0.5 0.5' ></Material>
          </Appearance>
        </Shape>
        <Transform translation='1 0 0'>
          <Switch DEF='keyLT0' whichChoice='-1'>
            <Shape DEF='zero'>
              <Text string='"value is 0"' >
                <FontStyle DEF='left' justify='"BEGIN" "END"'></FontStyle>
              </Text>
              <Appearance DEF='DescriptionColor'>
                <Material diffuseColor='0.9 0.5 0.5' ></Material>
              </Appearance>
            </Shape>
            <Shape DEF='one'>
              <Text string='"value is 1"' >
                <FontStyle USE='left'></FontStyle>
              </Text>
              <Appearance USE='DescriptionColor'></Appearance>
            </Shape>
            <Shape DEF='two'>
              <Text string='"value is 2"' >
                <FontStyle USE='left'></FontStyle>
              </Text>
              <Appearance USE='DescriptionColor'></Appearance>
            </Shape>
          </Switch>
        </Transform>
      </Transform>
      <Transform translation='-1 1 0'>
        <Shape>
          <Text string='"key = 0:"' >
            <FontStyle USE='right' ></FontStyle>
          </Text>
          <Appearance USE='keyColor'></Appearance>
        </Shape>
        <Transform translation='1 0 0'>  
          <Switch DEF='key0' whichChoice='-1'>
            <Shape USE='zero'></Shape>
            <Shape USE='one'></Shape>
            <Shape USE='two'></Shape>
          </Switch>
        </Transform>
      </Transform>
      <Transform translation='-1 0 0'>
        <Shape>
          <Text string='"key = 0.25:"' >
            <FontStyle USE='right' ></FontStyle>
          </Text>
          <Appearance USE='keyColor'></Appearance>
        </Shape>
        <Transform translation='1 0 0'>  
          <Switch DEF='key025' whichChoice='-1'>
            <Shape USE='zero'></Shape>
            <Shape USE='one'></Shape>
            <Shape USE='two'></Shape>
          </Switch>
        </Transform>
      </Transform>
      <Transform translation='-1 -1 0'>
        <Shape>
          <Text string='"key = 0.5:"' >
            <FontStyle USE='right' ></FontStyle>
          </Text>
          <Appearance USE='keyColor'></Appearance>
        </Shape>
        <Transform translation='1 0 0'>  
          <Switch DEF='key05' whichChoice='-1'>
            <Shape USE='zero'></Shape>
            <Shape USE='one'></Shape>
            <Shape USE='two'></Shape>
          </Switch>
        </Transform>
      </Transform>
      <Transform translation='-1 -2 0'>
        <Shape>
          <Text string='"key = 1.0:"' >
            <FontStyle USE='right' ></FontStyle>
          </Text>
          <Appearance USE='keyColor'></Appearance>
        </Shape>
        <Transform translation='1 0 0'>  
          <Switch DEF='key1' whichChoice='-1'>
            <Shape USE='zero'></Shape>
            <Shape USE='one'></Shape>
            <Shape USE='two'></Shape>
          </Switch>
        </Transform>
      </Transform>
      <Transform translation='-1 -3 0'>
        <Shape>
          <Text string='"key &gt; 1.0:"' >
            <FontStyle USE='right' ></FontStyle>
          </Text>
          <Appearance USE='keyColor'></Appearance>
        </Shape>
        <Transform translation='1 0 0'>  
          <Switch DEF='keyGT1' whichChoice='-1'>
            <Shape USE='zero'></Shape>
            <Shape USE='one'></Shape>
            <Shape USE='two'></Shape>
          </Switch>
        </Transform>
      </Transform>
      <TimeSensor DEF='starter' cycleInterval='0.1' loop='true'></TimeSensor>
      <ScalarInterpolator DEF='LT0_er' key='0 1' keyValue='-0.1 -0.1'></ScalarInterpolator>
      <ScalarInterpolator DEF='zero_er' key='0 1' keyValue='0.0 0.0'></ScalarInterpolator>
      <ScalarInterpolator DEF='zero25_er' key='0 1' keyValue='0.25 0.25'></ScalarInterpolator>
      <ScalarInterpolator DEF='zero5_er' key='0 1' keyValue='0.5 0.5'></ScalarInterpolator>
      <ScalarInterpolator DEF='one_er' key='0 1' keyValue='1.0 1.0'></ScalarInterpolator>
      <ScalarInterpolator DEF='GTone_er' key='0 1' keyValue='1.1 1.1'></ScalarInterpolator>
      <!-- run once only -->
      <ROUTE fromNode='starter' fromField='cycleTime' toNode='starter' toField='set_stopTime'></ROUTE>
      <!-- generate constant fraction -->
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='LT0_er' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='zero_er' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='zero25_er' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='zero5_er' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='one_er' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='starter' fromField='fraction_changed' toNode='GTone_er' toField='set_fraction'></ROUTE>
      <!-- 0.5 should be part of 0.5  to 1.0 interval -->
      <ROUTE fromNode='LT0_er' fromField='value_changed' toNode='ChooserLT0' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='zero_er' fromField='value_changed' toNode='Chooser0' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='zero25_er' fromField='value_changed' toNode='Chooser025' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='zero5_er' fromField='value_changed' toNode='Chooser05' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='one_er' fromField='value_changed' toNode='Chooser1' toField='set_fraction'></ROUTE>
      <ROUTE fromNode='GTone_er' fromField='value_changed' toNode='ChooserGT1' toField='set_fraction'></ROUTE>
      <!-- value_changed should be 1.0 -->
      <ROUTE fromNode='ChooserLT0' fromField='value_changed' toNode='keyLT0' toField='set_whichChoice' ></ROUTE>
      <ROUTE fromNode='Chooser0' fromField='value_changed' toNode='key0' toField='set_whichChoice' ></ROUTE>
      <ROUTE fromNode='Chooser025' fromField='value_changed' toNode='key025' toField='set_whichChoice' ></ROUTE>
      <ROUTE fromNode='Chooser05' fromField='value_changed' toNode='key05' toField='set_whichChoice' ></ROUTE>
      <ROUTE fromNode='Chooser1' fromField='value_changed' toNode='key1' toField='set_whichChoice' ></ROUTE>
      <ROUTE fromNode='ChooserGT1' fromField='value_changed' toNode='keyGT1' toField='set_whichChoice' ></ROUTE>    
  </Scene>
</X3D>

@michaliskambi
Copy link
Member

Thanks for reporting! Fixed. A 1-character fix in castle-engine/castle-engine@cab9977 :)

The snapshots on http://michalis.ii.uni.wroc.pl/castle-engine-snapshots/ will have a view3dscene binary with the fix in ~15 minutes.

integerkeytest_0

@andreasplesch
Copy link
Author

Thanks, that was quick ! I can confirm that the latest nightly has the fix. The function definition in the spec. gives a hint but has some issues as discussed in the mailing list, and I now submitted a spec. comment. The preceding interval definition [t0,t1) means that t0 is included in the interval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants