{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.2",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.2.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "component": [
          {
            "@name":"RigidBodyPhysics",
            "@level":2
          }
        ],
        "meta": [
          {
            "@name":"title",
            "@content":"BounceTrimesh.x3d"
          },
          {
            "@name":"description",
            "@content":"Example scene for RigidBodyPhysics component"
          },
          {
            "@name":"creator",
            "@content":"Alan Hudson and Justin Couch"
          },
          {
            "@name":"translator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"1 January 2008"
          },
          {
            "@name":"translated",
            "@content":"26 December 2008"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"reference",
            "@content":"http://www.xj3d.org/extensions/index.html#Physics"
          },
          {
            "@name":"reference",
            "@content":"originals/bounce_trimesh.x3dv"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/specifications/ISO-IEC-FDIS-19775-1.2-X3D-AbstractSpecification/Part01/components/rigid_physics.html"
          },
          {
            "@name":"warning",
            "@content":"under development"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/RigidBodyPhysics/BounceTrimesh.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"generator",
            "@content":"Xj3D converter, http://www.xj3d.org"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"02 September 2025"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "WorldInfo":
            {
              "@title":"BounceTrimesh.x3d"
            }
          },
          { "Viewpoint":
            {
              "@position":[0.0,0.0,4.0]
            }
          },
          { "Group":
            {
              "-children":[
                { "CollidableShape":
                  {
                    "@DEF":"BALL-GEOM",
                    "-shape":
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@emissiveColor":[1.0,0.0,0.0]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "Sphere":
                              {
                                "@radius":0.1
                              }
                            }
                        }
                      }
                  }
                },
                { "CollidableShape":
                  {
                    "@DEF":"GROUND-GEOM",
                    "@translation":[0.0,-0.5,0.0],
                    "-shape":
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@emissiveColor":[0.0,1.0,0.0]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "TriangleSet":
                              {
                                "-coord":
                                  { "Coordinate":
                                    {
                                      "@point":[-10.0,0.0,10.0,10.0,0.0,10.0,10.0,0.0,-10.0,-10.0,0.0,10.0,10.0,0.0,-10.0,-10.0,0.0,-10.0]
                                    }
                                  }
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@translation":[1.0,1.0,0.0],
              "-children":[
                { "Shape":
                  {
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@DEF":"INDICATOR-MATERIAL",
                                "@emissiveColor":[0.0,0.0,1.0]
                              }
                            }
                        }
                      },
                    "-geometry":
                      { "Sphere":
                        {
                          "@radius":0.2
                        }
                      }
                  }
                }
              ]
            }
          },
          { "RigidBodyCollection":
            {
              "@DEF":"BODY-COLLECTION",
              "-bodies":[
                { "RigidBody":
                  {
                    "@DEF":"BODY-1",
                    "@position":[0.0,2.0,0.0],
                    "-geometry":
                      { "CollidableShape":
                        {
                          "@USE":"BALL-GEOM"
                        }
                      }
                  }
                }
              ]
            }
          },
          { "CollisionSensor":
            {
              "@DEF":"COLLISION-OUTPUT",
              "-collider":
                { "CollisionCollection":
                  {
                    "@DEF":"COLLISION-GROUP",
                    "@bounce":1.0,
                    "@minBounceSpeed":1.0,
                    "-collidables":[
                      { "CollidableShape":
                        {
                          "@USE":"BALL-GEOM"
                        }
                      },
                      { "CollidableShape":
                        {
                          "@USE":"GROUND-GEOM"
                        }
                      }
                    ]
                  }
                }
            }
          },
          { "Script":
            {
              "@DEF":"CONTACT-SCRIPT",
              "@directOutput":true,
              "field": [
                {
                  "@name":"activeSensor",
                  "@accessType":"inputOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"indicatorColor",
                  "@accessType":"outputOnly",
                  "@type":"SFColor"
                },
                {
                  "@name":"set_jointContacts",
                  "@accessType":"inputOnly",
                  "@type":"MFNode"
                },
                {
                  "@name":"correctedContacts",
                  "@accessType":"outputOnly",
                  "@type":"MFNode"
                },
                {
                  "@name":"ground",
                  "@accessType":"initializeOnly",
                  "@type":"SFNode",
                  "-children":[
                    { "CollidableShape":
                      {
                        "@USE":"GROUND-GEOM"
                      }
                    }
                  ]
                }
              ],
              "#sourceCode":[
"",
"",
"ecmascript:",
"    function set_jointContacts(val) {",
"      for(i = 0; i < val.length; i++) {",
"        if(val[i].geometry1.equals(ground)) {",
"\t  val[i].geometry1 = null;",
"\t  val[i].body1 = null;",
"\t  val[i].bounce = 1;",
"\t}",
"",
"        if(val[i].geometry2.equals(ground)) {",
"\t  val[i].geometry2 = null;",
"\t  val[i].body2 = null;",
"\t  val[i].bounce = 1;",
"\t}",
"      }",
"      correctedContacts = val;",
"    }",
"",
"    function activeSensor(val) {",
"      if(val) {",
"        indicatorColor.r = 0;",
"        indicatorColor.g = 1;",
"        indicatorColor.b = 0;",
"      }\telse {",
"        indicatorColor.r = 1;",
"        indicatorColor.g = 0;",
"        indicatorColor.b = 0;",
"      }",
"    }",
"",
""
]
            }
          },
          { "ROUTE":
            {
              "@fromField":"contacts",
              "@fromNode":"COLLISION-OUTPUT",
              "@toField":"set_jointContacts",
              "@toNode":"CONTACT-SCRIPT"
            }
          },
          { "ROUTE":
            {
              "@fromField":"isActive",
              "@fromNode":"COLLISION-OUTPUT",
              "@toField":"activeSensor",
              "@toNode":"CONTACT-SCRIPT"
            }
          },
          { "ROUTE":
            {
              "@fromField":"indicatorColor",
              "@fromNode":"CONTACT-SCRIPT",
              "@toField":"emissiveColor",
              "@toNode":"INDICATOR-MATERIAL"
            }
          },
          { "ROUTE":
            {
              "@fromField":"correctedContacts",
              "@fromNode":"CONTACT-SCRIPT",
              "@toField":"set_contacts",
              "@toNode":"BODY-COLLECTION"
            }
          }
        ]
    }
  }
}