Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Issues/Notes #235

Merged
merged 45 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
89177a5
add ui slice
OlegMoshkovich Jun 17, 2022
bb090bd
Merge branch 'main' into Notes_2
OlegMoshkovich Jun 25, 2022
031e01e
fix lint spacing
OlegMoshkovich Jun 25, 2022
ef60825
add tests
OlegMoshkovich Jun 28, 2022
6549654
clean up issue card test
OlegMoshkovich Jun 28, 2022
dc1e322
add issue control test
OlegMoshkovich Jun 28, 2022
d63523e
fix issue control test
OlegMoshkovich Jun 28, 2022
aea9a81
testgin the issue control
OlegMoshkovich Jun 29, 2022
cd973b7
add test cases for issues and comments
OlegMoshkovich Jun 30, 2022
7486bde
refactor issues test
OlegMoshkovich Jun 30, 2022
7f684a6
refactor state names
OlegMoshkovich Jun 30, 2022
645dda2
refactor state names
OlegMoshkovich Jun 30, 2022
521b44c
adjust left corner
OlegMoshkovich Jun 30, 2022
4bc03aa
testing github call
OlegMoshkovich Jul 1, 2022
a3c1697
fix the tests
OlegMoshkovich Jul 1, 2022
041a400
clean up
OlegMoshkovich Jul 1, 2022
4f51173
clean up
OlegMoshkovich Jul 1, 2022
aaa79cf
fix spaces
OlegMoshkovich Jul 1, 2022
b9311db
issue formating
OlegMoshkovich Jul 1, 2022
fb164d8
use Effect
OlegMoshkovich Jul 1, 2022
0b0b49c
sort out run locally fetch logic
OlegMoshkovich Jul 4, 2022
7d8caff
reduce border radius
OlegMoshkovich Jul 4, 2022
eed4965
fix open issue locally
OlegMoshkovich Jul 4, 2022
ad55732
left corner
OlegMoshkovich Jul 5, 2022
0e7ae29
theme
OlegMoshkovich Jul 5, 2022
25f131d
theme
OlegMoshkovich Jul 5, 2022
cf2440c
working on the sidebar
OlegMoshkovich Jul 5, 2022
bea4e81
working on the sidebar
OlegMoshkovich Jul 5, 2022
2987850
resolve the get comments test
OlegMoshkovich Jul 5, 2022
591f298
snackbar message share test
OlegMoshkovich Jul 5, 2022
d0c2223
fixing is running locally for issue control
OlegMoshkovich Jul 5, 2022
079ba55
clean up
OlegMoshkovich Jul 5, 2022
765c712
place url code into sidedrawer
OlegMoshkovich Jul 5, 2022
fbf31b6
side drawer wrapper
OlegMoshkovich Jul 6, 2022
2d3d203
add side drawer
OlegMoshkovich Jul 6, 2022
c1b52b4
move the url use effect into the wrapper
OlegMoshkovich Jul 6, 2022
51164ec
debugging the side drawer
OlegMoshkovich Jul 6, 2022
fb149ba
testing side drawer
OlegMoshkovich Jul 6, 2022
88547cf
sort out the test
OlegMoshkovich Jul 6, 2022
921b0be
fix mobile drawer
OlegMoshkovich Jul 6, 2022
9c2bc88
Looks like you got a temp file in here
pablo-mayrgundter Jul 7, 2022
4b3bf1c
addressed the comments
OlegMoshkovich Jul 7, 2022
a306ab2
Merge branch 'Notes_2' of https://github.com/OlegMoshkovich/Share int…
OlegMoshkovich Jul 7, 2022
f863491
sorting out the url test
OlegMoshkovich Jul 8, 2022
c29d49d
fixed bad merge
OlegMoshkovich Jul 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
441 changes: 221 additions & 220 deletions docs/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.0-r320",
"version": "1.0.0-r332",
"main": "src/index.jsx",
"homepage": "https://github.com/bldrs-ai/Share",
"bugs": {
Expand Down
54 changes: 36 additions & 18 deletions src/Components/CameraControl.jsx
@@ -1,5 +1,6 @@
import React, {useEffect} from 'react'
import {useLocation} from 'react-router'
import useStore from '../store/useStore'
import debug from '../utils/debug'
import {
addHashListener,
Expand All @@ -24,11 +25,14 @@ import {roundCoord} from '../utils/math'
* @return {Object} React component
*/
export default function CameraControl({viewer}) {
const camera = viewer.IFC.context.ifcCamera.cameraControls
const setCameraControls = useStore((state) => state.setCameraControls)
const cameraControls = viewer.IFC.context.ifcCamera.cameraControls
setCameraControls(cameraControls)
const location = useLocation()
useEffect(() => {
onLoad(camera, location)
}, [camera, location])
onHash(location, cameraControls)
onLoad(location, cameraControls)
}, [location, cameraControls])
// NOTE: NOT DISPLAYED
return (
<div style={{display: 'none'}}>Camera</div>
Expand All @@ -43,38 +47,49 @@ export const CAMERA_PREFIX = 'c'
/**
* Set camera position from window location hash and add listener for
* hash change.
* @param {Object} camera The IFCjs camera
* @param {Object} location Either window.location or react-router location
* @param {Object} cameraControls obtained from the viewer
*/
function onLoad(camera, location) {
function onLoad(location, cameraControls) {
debug().log('CameraControl#onLoad')
onHash(camera, location)
addHashListener('camera', () => onHash(camera, location))
addHashListener('camera', () => onHash(location, cameraControls))
}


// exported for testing only
/**
* Sets the camera position to the coordinate encoded in the URL
* hash if it is present
* @param {Object} camera The IFCjs camera
* @param {Object} location window.location
* @param {Object} cameraControls obtained from the viewer
*/
export function onHash(camera, location) {
export function onHash(location, cameraControls) {
const encodedParams = getHashParams(location, CAMERA_PREFIX)
if (encodedParams == undefined) {
return
}
const coords = parseHashParams(encodedParams)
if (coords == undefined) {
setCameraFromEncodedPosition(encodedParams, cameraControls)
}


/**
* Set the camera position
* @param {String} encodedPosition camera position
* @param {Object} cameraControls obtained from the viewer
*/
export function setCameraFromEncodedPosition(encodedPosition, cameraControls) {
// addCameraUrlParams is accessed from the issue card and it is undefined on the first render
if (!cameraControls) {
return
}
const coords = parseHashParams(encodedPosition)
if (coords) {
camera.setPosition(coords[0], coords[1], coords[2], true)
cameraControls.setPosition(coords[0], coords[1], coords[2], true)
if (coords.length == 6) {
camera.setTarget(coords[3], coords[4], coords[5], true)
cameraControls.setTarget(coords[3], coords[4], coords[5], true)
}
}
addCameraUrlParams(cameraControls)
}


Expand Down Expand Up @@ -128,13 +143,16 @@ export function hasValidUrlParams() {

/**
* Adds camera coords to url.
* @param {Object} viewer IFCjs viewer that contains a camera.
* @param {Object} cameraControls obtained from the viewer
*/
export function addCameraUrlParams(viewer) {
const camera = viewer.IFC.context.ifcCamera
const position = camera.cameraControls.getPosition()
export function addCameraUrlParams(cameraControls) {
// addCameraUrlParams is accessed from the issue card and it is undefined on the first render
if (!cameraControls) {
return
}
const position = cameraControls.getPosition()
let camArr = roundCoord(...position, 2)
const target = camera.cameraControls.getTarget()
const target = cameraControls.getTarget()
if (target.x == 0 && target.y == 0 && target.z == 0) {
camArr = camArr.concat(0)
} else {
Expand Down
20 changes: 18 additions & 2 deletions src/Components/CameraControl.test.jsx
Expand Up @@ -27,7 +27,7 @@ test('CameraControl', () => {
test('onHash, position', () => {
const cam = new MockCamera()
const location = {hash: '#c:1,2,3'}
onHash(cam, location)
onHash(location, cam)
const expectCam = new MockCamera(1, 2, 3)
expectCam.setDoTween(true)
expect(cam).toStrictEqual(expectCam)
Expand All @@ -37,7 +37,7 @@ test('onHash, position', () => {
test('onHash, target', () => {
const cam = new MockCamera()
const location = {hash: '#c:1,2,3,4,5,6'}
onHash(cam, location)
onHash(location, cam)
const expectCam = new MockCamera(1, 2, 3, 4, 5, 6)
expectCam.setDoTween(true)
expect(cam).toStrictEqual(expectCam)
Expand Down Expand Up @@ -80,6 +80,22 @@ class MockCamera {
}


/**
* @return {Array} camera position
*/
getPosition() {
return [this.x, this.y, this.z]
}


/**
* @return {Array} camera target
*/
getTarget() {
return [this.x, this.y, this.z]
}


/**
* @param {Number} tx
* @param {Number} ty
Expand Down