1.1.0 • Published 4 years ago

@cofrico/3d-objects v1.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Objects-3d

Object-3d is build on top of react-three-fiber, a react reconciler for ThreeJS. Provides an abstraction for manage 3d objects easily

NPM JavaScript Style Guide

Install

npm install @cofrico/3d-objects

Usage

import  React  from  'react'
import { Layout } from  '@cofrico/layout-3d'
import { Object3d, Room } from  '@cofrico/layout-3d'

const FBXLoader = __CLIENT__ && require('three/examples/jsm/loaders/FBXLoader').FBXLoader

const  App = () => {
	return {

	<Layout>
    <Object3D
      id="123"
      type="type1"
      objectURL="/evaporador.fbx"
      loader={FBXLoader}
      position={[10, 0, 1]}
    />
    <Room
      nodes={[[-5, 5], [5, 5], [5, -5], [-5, -5]]}
      height={5}
      doors={[{ width: 2, height: 4, offset: 3, roomFaceIndex: 1 }]}
    >
      <Object3D
        id="456"
        type="type1"
        objectURL="/evaporador.fbx"
        loader={FBXLoader}
        position={[0, 0, 0]}
      />
    </Room>
  </Layout>
	}
}

Object3D Options

A wrapper to create objects from 3d object file without pain

NameTypeDescriptionDefaultRequired
objectURLstringpath to object filetrue
loaderobjectCan be FBXLoader, OBJLoader or any other ThreeJs loadertrue
positionarrayArray of 3d coordinates0, 0, 0false
rotationarrayArray of 3d coordinates0, 0, 0false
selectedboolSet object as selected or notfalsefalse
selectedColorstringColor used when the object is selected. Can be a hex, or other css color type'red'false
userDataobjectAn object that can be used to store custom data{ }false

Room Options

A wrapper to create rooms (extrude structures) from parameters. Rooms can have childs like other Rooms or Object3D

NameTypeDescriptionDefaultRequired
nodesarrayArray of 2d array coordinatestrue
heighnumberThe room heighttrue
childrennodeReact children nodefalse
doorsarrayArray of objects. Each object represents a door. See Door options false
userDataobjectAn object that can be used to store custom data{ }false
colorstringColor used when the object is selected. Can be a hex, or other css color type'#009b7f'false
disabledboolSet the object disabled or not, it only changes the color and opacityfalsefalse
selectedboolSet object as selected or notfalsefalse

###Door options A room can have many doors. Each one can be defined with this options

NameTypeDescriptionDefaultRequired
roomFaceIndexnumberAn index representing a room face, in the same order than room nodestrue
widthnumberDoor withtrue
heighnumberDoor heighttrue
offsetnumberOffset from right corner of the room to position the door0false
colorstringColor used when the object is selected. Can be a hex, or other css color type'#dcdcdcf'false
opacitynumberThe opacity of the door0.5false

Example

You have a simple playground to show the objects usage in /example folder. To run it, simply install the dependencies with yarn or npm install and run it from /example directory with yarn start. Then you can go to localhost:3000 to see the example working

License

MIT © Glue Digital(https://github.com/Glue Digital)

1.1.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago