Skip to content

Instantly share code, notes, and snippets.

const [wheelBody, wheelApi] = useSphere(() => ({
args : [2,2,2]
}));
const [wheelShapeLF, wheelApiLF] = [wheelBody, wheelApi];
const [wheelShapeRL, wheelApiRL] = [wheelBody, wheelApi];
const [wheelShapeRF, wheelApiRF] = [wheelBody, wheelApi];
const [wheelShapeRR, wheelApiRR] = [wheelBody, wheelApi];
const [wheelShape, wheelApi] = useSphere(() => ({
radius: 1.2,
}));
const [chassisShape, chassisApi] = useBox(() => ({
args: [5, 2, 0.5],
mass: 1,
}));
const zero = [0, 0, 0];
import { useFrame, useThree } from "react-three-fiber";
import store from "../store/store";
export default function Camera() {
const { camera } = useThree();
useFrame(() => {
camera.position !== store.getState().camera.position
? store.dispatch({ type: "CAMERA POSITION", position: camera.position })
: null;
import React from 'react'
import {Canvas, extend, Dom} from 'react-three-fiber'
import {Physics} from 'use-cannon'
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls';
//import Scene from './render/Scene'
import Controls from './render/Controls'
//import BoxHover from './3d/BoxHover'
import Plane from './3d/Plane'
import Joueur from './3d/Joueur'
//import Wall from './3d/Wall'
const store = createStore({
players : {},
movement : {
up: false,
down: false,
left: false,
right: false
},
currentId : 0,
score : computed(state => state.players[state.currentId].score),
const express = require('express');
const app = express();
const server = require('http').Server(app);
const io = require('socket.io')(server);
io.set('origins', '*:*');
server.listen(3002);
const players = [];
import {useHotkeys} from 'react-hotkeys-hook'
import { useStoreState, useStoreActions, action } from 'easy-peasy';
const KeyControls= (props) => {
const moveUP = useStoreActions(action => action.moveUP)
useHotkeys('up', event => {
if (event.type === "keydown") {
console.log("down");
import { createStore, useStoreState, action, useStoreActions, computed } from 'easy-peasy';
import React, {useEffect} from 'react';
import DatGui, { DatNumber, DatString, DatBoolean} from 'react-dat-gui';
import {socket} from '../Socket';
const store = createStore({
players : {},
movement : {
up: false,
down: false,
let playersList = {};
listeId.map((ident, i) => {
playersList[ident] = {
score : 0,
x : 0,
y : 0
}
})
fanch@Portable:~/NandY$ npm start
> nandy@0.0.0 start /home/fanch/NandY
> node ./bin/www
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '/home/fanch/NandY/bin/www'