This repository was archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
Maksim Nedoshev edited this page Mar 7, 2019
·
1 revision
- Download release.
- Add
<script src="Bronze.js"></script> - Setup engine
var Engine = new Bronze.Engine(canvas) - Setup camera
var camera = new Bronze.Camera(Engine) - Setup controls
var controls = new Bronze.Controls(Engine) - Load textures
let Texture = new Bronze.Texture("path/to/texture.png")
Texture.setColorRGBA(159, 136, 105, 255)
Engine.bindTexture(Texture) - Create some objects
var object = new Bronze.Object(Engine)
Load object from obj fileobject.loadFromObj("path/to/object.obj")Set textureobject.setTexture(Texture)Set position and rotation using appropriate methods.
// Getting canvas
let canvas = document.getElementById("canvas")
canvas.width = window.innerWidth
canvas.height = window.innerHeight
// Setup engine
let engine = new Bronze.Engine(canvas)
// Trigger canvasResized() on window resize.
window.addEventListener('resize', () => {
canvas.width = window.innerWidth
canvas.height = window.innerHeight
engine.canvasResized()
})
// Setup camera
let camera = new Bronze.Camera()
camera.setPosition(0, 800, 1500)
camera.setRotation(-45, 0, 0)
camera.setFieldOfView(90)
engine.setCamera(camera)
// Loading textures
let Texture = new Bronze.Texture("path/to/texture.jpg")
Texture.setColorRGBA(159, 136, 105, 255)
// Bind texture to engine
engine.bindTexture(Texture)
// Create an object
let object = new Bronze.Object(engine)
object.setTexture(Texture)
object.setPosition(250, 0, 800)
object.name = "My object"
object.loadFromObj("path/to/object/myObject.obj")
object.rotate(0, 45, 45)
object.setRotationPoint(0, 0, 0)
object.scale(10, 10, 10)
// Set custom animation for object.
let xPosition = 0, xDirection = -1
object.animate(60, () => {
object.setPosition(250 + xPosition, 0, 800)
xPosition += xDirection
if (xPosition < -3) {
xDirection = 1
} else if (xPosition > 3) {
xDirection = -1
}
})
// Run engine
engine.run()