Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.
Maksim Nedoshev edited this page Mar 7, 2019 · 1 revision

How to use

  1. Download release.
  2. Add <script src="Bronze.js"></script>
  3. Setup engine var Engine = new Bronze.Engine(canvas)
  4. Setup camera var camera = new Bronze.Camera(Engine)
  5. Setup controls var controls = new Bronze.Controls(Engine)
  6. Load textures
let Texture = new Bronze.Texture("path/to/texture.png")  
Texture.setColorRGBA(159, 136, 105, 255)  
Engine.bindTexture(Texture)  
  1. Create some objects var object = new Bronze.Object(Engine)
    Load object from obj file object.loadFromObj("path/to/object.obj") Set texture object.setTexture(Texture) Set position and rotation using appropriate methods.

Example

// 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()

Clone this wiki locally