Skip to content

OrbitControls: new + update#21

Merged
dmjio merged 1 commit intothree-hs:masterfrom
juliendehos:orbit-controls
Jul 8, 2025
Merged

OrbitControls: new + update#21
dmjio merged 1 commit intothree-hs:masterfrom
juliendehos:orbit-controls

Conversation

@juliendehos
Copy link
Contributor

OrbitControls is an addon in Three.js but I think it's important to have it in Three.hs.

=> (camera, JSVal)
-> THREE.Three OrbitControls
new (cam, elt) = do
v <- jsg ("OrbitControls" :: JSString)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliendehos should this be THREE.OrbitControls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In JS, we use OrbitControls like this:

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
...
const controls = new OrbitControls( camera, renderer.domElement );

The PR works if we add this in the index.html:

    <script  type="module" >
      import * as THREE from 'three';
      window.THREE = THREE;
      import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
      window.OrbitControls = OrbitControls;
    </script>

(see https://github.com/haskell-miso/three-miso/blob/c54fe71dae6566c3d446d5691b18ef4699c986fe/static/index.html)

v <- jsg ("OrbitControls" :: JSString)
OrbitControls <$> J.new v (cam, elt)
-----------------------------------------------------------------------------
update :: Method OrbitControls () Bool -- TODO () -> (Maybe Double)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Double ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to handle optional arguments in three.hs.
The PR is a minimal integration of OrbitControls, we can update that later.

@dmjio dmjio merged commit 8ac6bdb into three-hs:master Jul 8, 2025
1 check passed
@juliendehos juliendehos deleted the orbit-controls branch July 9, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants