threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {IObject3D, IObject3DEvent, IObject3DEventTypes, IObject3DUserData, IObjectSetDirtyOptions} from './IObject'
  2. import {Color, Scene} from 'three'
  3. import {IShaderPropertiesUpdater} from '../materials'
  4. import {ICamera} from './ICamera'
  5. import {Box3B} from '../three'
  6. import {ITexture} from './ITexture'
  7. export interface AddObjectOptions {
  8. /**
  9. * Add directly to the {@link RootScene} object instead of {@link RootScene.modelRoot}
  10. * @default false
  11. */
  12. addToRoot?: boolean
  13. /**
  14. * Automatically center the object in the scene.
  15. * @default false
  16. */
  17. autoCenter?: boolean,
  18. /**
  19. * Add a license to the object
  20. */
  21. license?: string,
  22. /**
  23. * Automatically scale the object according to its bounding box and the {@link autoScaleRadius} setting
  24. * @default false
  25. */
  26. autoScale?: boolean
  27. /**
  28. * Radius to use for {@link autoScale}
  29. * @default 2
  30. */
  31. autoScaleRadius?: number
  32. /**
  33. * any attached viewer config will be ignored if this is set to true
  34. * @default true
  35. */
  36. importConfig?: boolean
  37. /**
  38. * Clear the viewer scene objects before the new object is added. Same as {@link disposeSceneObjects} but does not dispose the objects.
  39. */
  40. clearSceneObjects?: boolean
  41. /**
  42. * Dispose all the scene objects before the new object is added. Same as {@link clearSceneObjects} but also disposes the objects.
  43. */
  44. disposeSceneObjects?: boolean
  45. // TODO; add more options
  46. }
  47. // | string
  48. export type ISceneEventTypes = IObject3DEventTypes | 'sceneUpdate' | 'addSceneObject' |
  49. 'mainCameraChange' | 'mainCameraUpdate' | 'environmentChanged' | 'backgroundChanged' |
  50. 'update' | // todo: deprecate, use 'sceneUpdate' instead
  51. 'textureAdded' | // todo remove
  52. 'activeCameraChange' | 'activeCameraUpdate' | // todo: deprecate
  53. 'sceneMaterialUpdate' // todo deprecate: use 'materialUpdate' instead
  54. // | string
  55. export interface ISceneEvent<T extends string = ISceneEventTypes> extends IObject3DEvent<T> {
  56. scene?: IScene | null
  57. // change?: string
  58. }
  59. export type ISceneSetDirtyOptions = IObjectSetDirtyOptions
  60. export type ISceneUserData = IObject3DUserData
  61. export type IWidget = IObject3D // todo
  62. export interface IScene<E extends ISceneEvent = ISceneEvent, ET extends ISceneEventTypes = ISceneEventTypes>
  63. extends Scene<E, ET>, IObject3D<E, ET>, IShaderPropertiesUpdater {
  64. readonly visible: boolean;
  65. readonly isScene: true;
  66. mainCamera: ICamera;
  67. type: 'Scene';
  68. toJSON(): any; // todo
  69. modelRoot: IObject3D;
  70. // sceneObjects: ISceneObject[];
  71. // environmentLight?: IEnvironmentLight;
  72. // processors: ObjectProcessorMap<'environment' | 'background'>
  73. addObject<T extends IObject3D>(imported: T, options?: AddObjectOptions): T&IObject3D;
  74. setDirty(e?: ISceneSetDirtyOptions): void
  75. // sceneBounds: Box3B; // last computed scene bounds
  76. getBounds(precise?: boolean, ignoreInvisible?: boolean): Box3B;
  77. backgroundIntensity: number;
  78. envMapIntensity: number;
  79. fixedEnvMapDirection: boolean;
  80. environment: ITexture | null;
  81. background: ITexture | Color | null | 'environment';
  82. backgroundColor: Color | null;
  83. // addWidget(widget: IWidget, options?: AnyOptions): void; // todo
  84. defaultCamera: ICamera
  85. userData: ISceneUserData
  86. // region deprecated
  87. /**
  88. @deprecated use {@link getObjectByName} instead
  89. * @param name
  90. * @param parent
  91. */
  92. findObjectsByName(name: string, parent?: any): any[];
  93. /**
  94. * @deprecated renamed to {@link mainCamera}
  95. */
  96. activeCamera: ICamera;
  97. // endregion
  98. // region inherited type fixes
  99. // re-declaring from IObject3D because: https://github.com/microsoft/TypeScript/issues/16936
  100. traverse(callback: (object: IObject3D) => void): void
  101. traverseVisible(callback: (object: IObject3D) => void): void
  102. traverseAncestors(callback: (object: IObject3D) => void): void
  103. getObjectById<T extends IObject3D = IObject3D>(id: number): T | undefined
  104. getObjectByName<T extends IObject3D = IObject3D>(name: string): T | undefined
  105. getObjectByProperty<T extends IObject3D = IObject3D>(name: string, value: string): T | undefined
  106. copy(source: this, recursive?: boolean): this
  107. clone(recursive?: boolean): this
  108. add(...object: IObject3D[]): this
  109. remove(...object: IObject3D[]): this
  110. parent: IObject3D | null
  111. children: IObject3D[]
  112. // endregion
  113. }