Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React, { useCallback } from 'react';
import "@babylonjs/core/Physics/physicsEngineComponent" // side-effect adds scene.enablePhysics function
import { Vector3, PhysicsImpostor, Mesh, Nullable } from '@babylonjs/core';
import { CannonJSPlugin } from '@babylonjs/core/Physics/Plugins'
import { Scene, Engine, withBabylonJS } from 'react-babylonjs';
import './App.css';
import * as CANNON from 'cannon';
window.CANNON = CANNON;
const EngineWithContext = withBabylonJS(Engine);
const gravityVector = new Vector3(0, -9.81, 0);
let sphere: Nullable = null;
const onButtonClicked = () => {
if (sphere !== null) {
sphere.physicsImpostor!.applyImpulse(Vector3.Up().scale(10), sphere.getAbsolutePosition())
}
}
const App: React.FC = () => {
const sphereRef = useCallback(node => {
sphere = node.hostInstance;
}, []);
return (
<div></div>
rootUrl = {\`\${baseUrl}Avocado/glTF/\`}
position = { new Vector3(-0.02, this.state.avocadoYPos, 0) }
scaling={new Vector3(this.state.avocadoScaling,
this.state.avocadoScaling, this.state.avocadoScaling)}
/>
`}
)
}
}
export default withBabylonJS(WithModel)