{"id":16126776,"url":"https://github.com/mikolalysenko/orbiter","last_synced_at":"2025-04-15T02:52:18.206Z","repository":{"id":28705865,"uuid":"32226388","full_name":"mikolalysenko/orbiter","owner":"mikolalysenko","description":"3D quaternion orbit camera with mouse input","archived":false,"fork":false,"pushed_at":"2015-03-14T21:27:27.000Z","size":103,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T02:52:12.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikolalysenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-14T18:37:30.000Z","updated_at":"2024-05-21T17:07:59.000Z","dependencies_parsed_at":"2022-07-24T16:01:57.426Z","dependency_job_id":null,"html_url":"https://github.com/mikolalysenko/orbiter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Forbiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Forbiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Forbiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikolalysenko%2Forbiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikolalysenko","download_url":"https://codeload.github.com/mikolalysenko/orbiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997087,"owners_count":21195797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T21:40:19.677Z","updated_at":"2025-04-15T02:52:18.182Z","avatar_url":"https://github.com/mikolalysenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"orbiter\n=======\nAn orbiting camera with mouse input bindings.  This is similar to 3d-view-controls, except it doesn't do mode switching and fancy property syntactic sugar, making it much lighter weight.\n\nDefault controls:\n\nButton | Interaction\n-------|------------\nLeft mouse | Rotate\nShift + left mouse *or* scroll horizontally | Roll\nRight mouse | Pan\nMiddle mouse *or* scroll vertically | Zoom\n\n\n# Example\n\n```javascript\nvar createCamera = require('../orbiter')\nvar bunny = require('bunny')\nvar perspective = require('gl-mat4/perspective')\nvar createMesh = require('gl-simplicial-complex')\n\nvar canvas = document.createElement('canvas')\ndocument.body.appendChild(canvas)\nwindow.addEventListener('resize', require('canvas-fit')(canvas))\n\nvar gl = canvas.getContext('webgl')\n\nvar camera = createCamera(canvas, {\n  eye:    [50,0,0],\n  center: [0,0,0],\n  zoomMax: 500\n})\n\nvar mesh = createMesh(gl, {\n  cells:      bunny.cells,\n  positions:  bunny.positions,\n  colormap:   'jet'\n})\n\nfunction render() {\n  requestAnimationFrame(render)\n  if(camera.tick()) {\n    gl.viewport(0, 0, canvas.width, canvas.height)\n    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)\n    gl.enable(gl.DEPTH_TEST)\n    mesh.draw({\n      projection: perspective([], Math.PI/4, canvas.width/canvas.height, 0.01, 1000),\n      view: camera.matrix\n    })\n  }\n}\nrender()\n```\n\n# Interface\n\n## Constructor\n\n#### `var camera = require('orbiter')(element[, options])`\nCreates a new camera object.\n\n* `element` is a DOM node onto which the orbiter is attached\n* `options` is an object with the following optional properties:\n    + `eye` - the position of the camera in world coordinates (Default `[0,0,10]`)\n    + `center` - the target of the camera in world coordinates (Default `[0,0,0]`)\n    + `up` - the up vector of the camera (Default `[0,1,0]`)\n    + `inputEnabled` if set to false, then disables input (Default `true`)\n    + `delay` - amount to delay interactions by for interpolation in ms (Default `16`)\n    + `rotateSpeed` - rotation scaling factor (Default `1`)\n    + `zoomSpeed` - zoom scaling factor (Default `1`)\n    + `translateSpeed` - translation/panning scale factor (Default `1`)\n    + `flipX` - flip X axis for rotations (Default `false`)\n    + `flipY` - flip Y axis for rotations (Default `false`)\n    + `zoomMin` - minimum zoom distance (Default `0.01`)\n    + `zoomMax` - maximum zoom distance (Default `Infinity`)\n\n## Geometric properties\n\n#### `camera.matrix`\nA 4x4 matrix encoded as a length 16 array representing the homogeneous transformation from world coordinates to view (camera) coordinates.\n\n#### `camera.eye`\nThe position of the camera in world coordinates\n\n#### `camera.up`\nA vector pointing up in world coordinates\n\n#### `camera.center`\nThe target of the camera in world coordinates\n\n#### `camera.distance`\nEuclidean distance from `eye` to `center`\n\n## Methods\n\n#### `camera.tick()`\nUpdates the camera state.  Call this before each frame is rendered to compute the current state of the camera.\n\n**Returns** `true` if the state of the camera has changed since the last call to `tick`\n\n#### `camera.lookAt(center, eye, up)`\nSets the camera center/eye/up vector to look at a fixed target\n\n* `center` is the new center/target for the camera\n* `eye` is the position of the camera in world coordinates\n* `up` is a vector pointing up\n\n#### `camera.box(lo, hi)`\nTargets the camera at a bounding box.  This is a short cut for skipping some of the boilerplate associated with lookAt\n\n* `lo` is the lower bound on the box\n* `hi` is the upper bound on the box\n\n#### `camera.rotate(yaw, pitch, roll)`\nApplies an incremental rotation to the camera\n\n* `yaw` is the amount to rotate about the y-axis (in xz plane of camera)\n* `pitch` is the amount to rotate about the x-axis (in yz plane of camera)\n* `roll` is the amount to rotate about the forward axis (in xy plane of camera)\n\n#### `camera.pan(dx, dy, dz)`\nApplies a relative motion to the camera, moving in view coordinates\n\n* `dx,dy,dz` are the components of the camera motion vector\n\n#### `camera.translate(dx, dy, dz)`\nTranslates the camera in world coordinates\n\n* `dx,dy,dz` are the components of the translation vector\n\n## Tuning parameters\n\n#### `camera.distanceLimits`\nA 2D array representing the `[lo,hi]` bounds on the zoom distance.  Note that `0 \u003c lo \u003c hi`.\n\n#### `camera.flipX`\nA flag controlling whether the camera rotation is flipped along the x-axis\n\n#### `camera.flipY`\nA flag controlling whether the camera rotation is flipped along the y-axis\n\n#### `camera.delay`\nThe amount of delay on the interpolation of the camera state in ms\n\n#### `camera.rotateSpeed`\nCamera rotation speed scaling factor\n\n#### `camera.zoomSpeed`\nCamera zoom speed scaling factor\n\n#### `camera.translateSpeed`\nCamera translation speed scaling factor\n\n#### `camera.element`\nThe DOM element the camera is attached to\n\n# License\n(c) 2015 Mikola Lysenko. MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikolalysenko%2Forbiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikolalysenko%2Forbiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikolalysenko%2Forbiter/lists"}