architwin 1.0.32 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -16
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -24,11 +24,13 @@ ArchiTwin Library
|
|
|
24
24
|
- [Loading and Interacting with 3D/2D Objects](#loading-and-interacting-with-3d2d-objects)
|
|
25
25
|
- [What is an Object?](#what-is-an-object)
|
|
26
26
|
- [Loading Objects](#loading-objects)
|
|
27
|
+
- [Accessing List of Rendered Objects and Object Structure](#accessing-list-of-rendered-objects-and-object-structure)
|
|
27
28
|
- [Transforming Objects](#transforming-objects)
|
|
28
29
|
- [Transforming Object by clicking it](#transforming-object-by-clicking-it)
|
|
29
|
-
- [
|
|
30
|
+
- [Programmatically transforming objects](#programmatically-transforming-objects)
|
|
30
31
|
- [Undoing and Redoing Transformation Changes](#undoing-and-redoing-transformation-changes)
|
|
31
32
|
- [Adding Objects To Your Space](#adding-objects-to-your-space)
|
|
33
|
+
- [Programmatically Add Objects](#programmatically-add-objects)
|
|
32
34
|
- [Creating a Customizable Media Screen](#creating-a-customizable-media-screen)
|
|
33
35
|
- [Adding a Media Screen](#adding-a-media-screen)
|
|
34
36
|
- [Media Screen Parameter Reference](#media-screen-parameter-reference)
|
|
@@ -639,6 +641,85 @@ import * as atwin from 'architwin'
|
|
|
639
641
|
|
|
640
642
|
atwin.nearbyObjects //Gets updated everytime the User camera moves
|
|
641
643
|
```
|
|
644
|
+
|
|
645
|
+
### Accessing List of Rendered Objects and Object Structure
|
|
646
|
+
|
|
647
|
+
Objects that have been loaded and **rendered** into the 3D space are stored in an array called _3DXObjects which you can access by doing calling it this way
|
|
648
|
+
|
|
649
|
+
```typescript
|
|
650
|
+
atwin._3DXObjects
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
All the elements in this array implement the `IObjectData` interface. Each element in the array contains all the data you would need manipulate the object.
|
|
654
|
+
|
|
655
|
+
*interface used* (TS)
|
|
656
|
+
```typescript
|
|
657
|
+
interface IObjectData {
|
|
658
|
+
collider?: any
|
|
659
|
+
object: IShowcaseObject
|
|
660
|
+
component: Scene.IComponent
|
|
661
|
+
node: Scene.INode
|
|
662
|
+
type?: string
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
Each object element inside `atwin._3DXObjects` contains the value keys:
|
|
667
|
+
|
|
668
|
+
**collider:** Collider components define the shape of an 3D/2D object for the purposes of physical collisions. A collider, which is invisible, does not need to be the exact same shape as the GameObject’s mesh.
|
|
669
|
+
|
|
670
|
+
**object:** The object key is an object that implements the `IShowcaseObject` interface. This is one of the most important values as the object contains all the information about an object such as its id,name,position,rotation,scale,amazon_uri link, and etc. You can look at the interface below to view the full makeup of the object key.
|
|
671
|
+
|
|
672
|
+
*interface used* (TS)
|
|
673
|
+
```typescript
|
|
674
|
+
export interface IShowcaseObject {
|
|
675
|
+
id: number;
|
|
676
|
+
showcase_id: number;
|
|
677
|
+
object_id: number;
|
|
678
|
+
user_id: number;
|
|
679
|
+
object_position: {
|
|
680
|
+
x: number;
|
|
681
|
+
y: number;
|
|
682
|
+
z: number;
|
|
683
|
+
};
|
|
684
|
+
object_rotation: {
|
|
685
|
+
x: number;
|
|
686
|
+
y: number;
|
|
687
|
+
z: number;
|
|
688
|
+
};
|
|
689
|
+
object_scale: {
|
|
690
|
+
x: number;
|
|
691
|
+
y: number;
|
|
692
|
+
z: number;
|
|
693
|
+
};
|
|
694
|
+
autoplay: boolean;
|
|
695
|
+
autoplay_distance: number;
|
|
696
|
+
offset_position: number;
|
|
697
|
+
offset_rotation: number;
|
|
698
|
+
position_unit: string;
|
|
699
|
+
showcase_object_name: string;
|
|
700
|
+
is_deleted: boolean;
|
|
701
|
+
is_read: boolean;
|
|
702
|
+
is_new: boolean;
|
|
703
|
+
object_data: I3DObject;
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
**component:** This objects contains functions and variables responsible for intializing, updating, and destroying a rendered objects mesh, texture, etc. This object also contains the three.js instance. Since the 3D space is rendered with Three.js under the hood. You can use this instance to invoke methods made available by three.js. This gives you a lot of flexibility and control provided you know how to use it. This documentation will not cover Three.js specific methods. Visit their [official website](https://threejs.org/) if you want to learn more about it.
|
|
708
|
+
|
|
709
|
+
**node:** The node is responsible for managing the lifecycle of a 3D/2D objects. The node can be used to `start()` and `stop()` a rendered model. Invoking `start()` will render the model into the scene while `stop()` will destroy it and remove it from the scene.
|
|
710
|
+
|
|
711
|
+
**type:** A string that states the file or object type of a 3D/2D object. The file type could be any of the following
|
|
712
|
+
|
|
713
|
+
**Valid Types**
|
|
714
|
+
|
|
715
|
+
| type | context | description |
|
|
716
|
+
| :----: | :----: | :---: |
|
|
717
|
+
| GLB | 3D model | A 3D model with or without animation |
|
|
718
|
+
| FBX | 3D model | A 3D model with or without animation |
|
|
719
|
+
| FRAME | Media Screen | A customizable [media screen](#creating-a-customizable-media-screen) |
|
|
720
|
+
| ZIP | slideshow | A zip file rendered as a image slideshow |
|
|
721
|
+
|
|
722
|
+
The `atwin.selectedObject` variable is an example of a variable that implements this interfacea and contains this data.
|
|
642
723
|
### Transforming Objects
|
|
643
724
|
|
|
644
725
|
Transformation such as translate, scale, and rotate are actions used to manipulate objects in a 3D space. These transformations allow you to change an object's position, size, and orientation respectively.
|
|
@@ -670,7 +751,7 @@ If you wish the to access the object data of the object that has been clicked on
|
|
|
670
751
|
console.log("Selected object data",atwin.selectedObject)
|
|
671
752
|
```
|
|
672
753
|
|
|
673
|
-
####
|
|
754
|
+
#### Programmatically transforming objects
|
|
674
755
|
|
|
675
756
|
If you need to transform the position,rotation, and scale of one or more objects without having to use the mouse then the
|
|
676
757
|
`setObjectTransformation()` method will allow you to do so. The method accepts the following parameters
|
|
@@ -688,10 +769,10 @@ The **transform** object contains the following key-value pairs. These values wh
|
|
|
688
769
|
| object_rotation | Vector3 | yes | none | Valid x,y,z coordinates|
|
|
689
770
|
| object_scale | Vector3 | yes | none | Valid x,y,z coordinates|
|
|
690
771
|
|
|
691
|
-
In this example, we will get a random 3D model from the array of rendered objects stored in `atwin.
|
|
772
|
+
In this example, we will get a random 3D model from the array of rendered objects stored in `atwin._3DXObjects` and manipulate it using the method. The object we will be manipulating in this example is a 3D model with a file type of GLB (You can also transform other object types such as a media screen). This will return a javascript object that contains the rendered object's data which implement the `IObjectData` interface. You can know more about that by going to this section
|
|
692
773
|
|
|
693
774
|
```typescript
|
|
694
|
-
const targetObject = atwin.
|
|
775
|
+
const targetObject = atwin._3DXObjects.find(obj => obj.object.object_data.object_type == 'GLB')
|
|
695
776
|
|
|
696
777
|
const transform = {
|
|
697
778
|
object_position: {
|
|
@@ -742,8 +823,14 @@ In order to add an object, you may use the `addObjectToScene()` method.
|
|
|
742
823
|
|
|
743
824
|
| parameter | type | required | values |
|
|
744
825
|
| :----: | :----: | :---: | :---: |
|
|
745
|
-
| object | I3DObject | yes | object |
|
|
746
|
-
| option |
|
|
826
|
+
| object | I3DObject | yes | object payload |
|
|
827
|
+
| option | ObjectConfig | no | valid config object |
|
|
828
|
+
|
|
829
|
+
There are two ways you can use the `addObjectToScene()` method. We will go through each one
|
|
830
|
+
|
|
831
|
+
#### Programmatically Add Objects
|
|
832
|
+
|
|
833
|
+
If you wish to add new object to your space to a pre-defined position, you can use the `addObjectToScene()` method an pass the object data along
|
|
747
834
|
|
|
748
835
|
```typescript
|
|
749
836
|
atwin.addObjectToScene(object:I3DObject, option:object)
|
|
@@ -776,7 +863,7 @@ The **transform** object is an object that contains the following key-value pair
|
|
|
776
863
|
|
|
777
864
|
By default, your media screen will show a blank white canvas if you set the mediaUrl parameter of the `addMediaScreen()` method as an empty string or `undefined`.
|
|
778
865
|
|
|
779
|
-
**IMPORTANT:** The link to your media you provide to the mediaUrl **MUST** be publicly accessible and have the appropriate CORS headers, otherwise,
|
|
866
|
+
**IMPORTANT:** The link to your media you provide to the mediaUrl **MUST** be publicly accessible and have the appropriate CORS headers, otherwise, your media will not load into the media screen.
|
|
780
867
|
|
|
781
868
|
There are many ways you can use this method to add a media screen to your 3D space. Let's go through each one.
|
|
782
869
|
|
|
@@ -806,9 +893,9 @@ atwin.addMediaScreen('',transform)
|
|
|
806
893
|
|
|
807
894
|
If done correctly, you should be able to see your media screen in your intended position. This method is useful if you already the have position,rotation, and scale values stored in a database or possibly in a local array
|
|
808
895
|
|
|
809
|
-
**Method 2: Adding with click method
|
|
896
|
+
**Method 2: Adding with click method using getTargetPosition**
|
|
810
897
|
|
|
811
|
-
The library has several helper methods that provide a range of commmon functionalities to help you achieve certain actions easier. If for example, you do not have your
|
|
898
|
+
The library has several helper methods that provide a range of commmon functionalities to help you achieve certain actions easier. If for example, you do not have your intended position coordinates stored in the database or in a local area and wish to click a specific area of the 3D space and get that the coordinates of the area you clicked, you may do some by using the `getTargetPosition()` helper method in tangent with the `addMediaScreen()` method to do so. You can [click here](#getting-the-coordinates-of-a-clicked-area-in-the-3d-space) to know more about the `getTargetPosition()` method
|
|
812
899
|
|
|
813
900
|
Here is an example of how you can use the two methods together. This is just one example, it is up to you on how you wish to combine different methods provided by the library
|
|
814
901
|
|
|
@@ -831,7 +918,7 @@ atwin.getTargetPosition(myCallbackFunction)
|
|
|
831
918
|
```
|
|
832
919
|
|
|
833
920
|
#### Attaching an image or video to a Media Screen
|
|
834
|
-
You can think of a media screen as a blank canvas whose content is totally up to you. If you wish to set the
|
|
921
|
+
You can think of a media screen as a blank canvas whose content is totally up to you. If you wish to set the content of the media screen, you may use the `attachMediaScreenContent()` method.
|
|
835
922
|
|
|
836
923
|
**Attach Media Screen Parameters**
|
|
837
924
|
|
|
@@ -841,9 +928,9 @@ You can think of a media screen as a blank canvas whose content is totally up to
|
|
|
841
928
|
| mediaUrl | string | yes | none | valid public url to the media|
|
|
842
929
|
| mediaType | string | no | image | 'image' or 'video' |
|
|
843
930
|
|
|
844
|
-
**IMPORTANT:** The link to your media you provide to the mediaUrl **MUST** be publicly accessible and have the appropriate CORS headers, otherwise,
|
|
931
|
+
**IMPORTANT:** The link to your media you provide to the mediaUrl **MUST** be publicly accessible and have the appropriate CORS headers, otherwise, your media will not load into the media screen.
|
|
845
932
|
|
|
846
|
-
In this example, we are using a link pointing to the media stored in an s3 bucket as the mediaUrl and a random media screen id. You will have to substitute the id with an actual id of a rendered media screen.
|
|
933
|
+
In this example, we are using a link pointing to the media stored in an s3 bucket as the mediaUrl and a random media screen id. You will have to substitute the id with an actual id of a **rendered** media screen.
|
|
847
934
|
|
|
848
935
|
Example with image:
|
|
849
936
|
```typescript
|
|
@@ -863,10 +950,10 @@ atwin.attachMediaScreenContent(targetMediaScreenId,validUrl,'video')
|
|
|
863
950
|
|
|
864
951
|
When setting a video as the media screen content. You can use the `setVideoPlayback()` method to programmatically play,pause,mute,and unmute a video. You can navigate to the [playback controls section](#setting-video-playback-in-the-space) to learn more about the method. Here is an example on how to use it.
|
|
865
952
|
|
|
866
|
-
In this example, we are getting a random media screen from the `atwin.
|
|
953
|
+
In this example, we are getting a random media screen from the `atwin._3DXObjects` array which contains all the objects rendered in the space. Media screens whose media type is a video will have a variable called `planeElement` inside the object's `component` which contains an HTML video element that we can manipulate using the `setVideoPlayback()` method. Please take note that this variable is not accessible if the media type of the media screen content is an image.
|
|
867
954
|
|
|
868
955
|
|
|
869
|
-
*Interface used*
|
|
956
|
+
*Interface used* (TS)
|
|
870
957
|
```typescript
|
|
871
958
|
export interface IObjectData {
|
|
872
959
|
collider?: any
|
|
@@ -879,7 +966,7 @@ export interface IObjectData {
|
|
|
879
966
|
|
|
880
967
|
*Example*
|
|
881
968
|
```typescript
|
|
882
|
-
const randomMediaScreen:IObjectData = atwin.
|
|
969
|
+
const randomMediaScreen:IObjectData = atwin._3DXObjects.find(obj => obj.object.object_data.object_type == 'FRAME')
|
|
883
970
|
|
|
884
971
|
setVideoPlayback('play',randomMediaScreen.component.planeElement)
|
|
885
972
|
```
|
|
@@ -888,7 +975,7 @@ You can use the [transform controls](#transforming-objects) to change the positi
|
|
|
888
975
|
|
|
889
976
|
### Getting the coordinates of a clicked area in the 3D space
|
|
890
977
|
|
|
891
|
-
The 3D space you walk around is a three dimensional mesh under the hood. Every point in this space has an x,y,z
|
|
978
|
+
The 3D space you walk around in is a three dimensional mesh under the hood. Every point in this space has an x,y,z coordinate. These coordinates are important since it allows us to anchor objects into the 3D space and navigate around it. You may at times need the ability to get the coordinates of an area in the space. You can do this by utilizing the `getTargetPosition()` method.
|
|
892
979
|
|
|
893
980
|
**Parameter Reference**
|
|
894
981
|
| parameter | type | required | default | values |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "architwin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "ArchiTwin Library for Matterport",
|
|
5
5
|
"main": "./lib/architwin.min.js",
|
|
6
6
|
"types": "./lib/architwin.d.ts",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@superviz/matterport-plugin": "^0.8.7",
|
|
31
31
|
"@superviz/sdk": "^4.10.0",
|
|
32
|
-
"architwin": "^1.0.25",
|
|
33
32
|
"aws-sdk": "^2.1385.0",
|
|
34
33
|
"axios": "^1.4.0",
|
|
35
34
|
"jszip": "^3.10.1",
|