### Module3D Initialization Source: https://context7.com/thenexusavenger/module3d/llms.txt Initializes a new Module3D object from a BasePart or Model. The module automatically handles setup within a ViewportFrame. ```APIDOC ## Module3D.new(ModelOrPart) ### Description Creates a new Module3D object from a BasePart or Model. The module automatically wraps BaseParts in a Model container, positions the object in a far location to prevent physics interactions, and sets up the ViewportFrame with a properly positioned camera. ### Method `Module3D.new` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) -- Create from a BasePart local part = Instance.new("Part") part.Size = Vector3.new(4, 4, 4) part.BrickColor = BrickColor.new("Bright blue") local model3D = Module3D.new(part) model3D.Parent = script.Parent.ScreenGui.Frame model3D.Visible = true -- Create from an existing Model local characterModel = ReplicatedStorage:WaitForChild("CharacterPreview"):Clone() local characterDisplay = Module3D.new(characterModel) characterDisplay.Parent = script.Parent.ScreenGui.CharacterFrame characterDisplay.Visible = true ``` ### Response #### Success Response (200) Returns a Module3D object. #### Response Example (No specific response example provided, but it returns a Module3D instance.) ``` -------------------------------- ### Create Animated 3D Item Display with Rotation Source: https://context7.com/thenexusavenger/module3d/llms.txt This example demonstrates creating an animated 3D item display with camera adjustments and rotation effects using RunService.RenderStepped for animation. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local displayFrame = script.Parent:WaitForChild("Frame") local itemModel = ReplicatedStorage:WaitForChild("Items"):WaitForChild("GoldenSword") -- Create the 3D display attached to the frame local itemDisplay = Module3D:Attach3D(displayFrame, itemModel) -- Configure the display itemDisplay:SetDepthMultiplier(1.2) itemDisplay.CurrentCamera.FieldOfView = 40 itemDisplay.BackgroundTransparency = 1 itemDisplay.Visible = true -- Animate the rotation local connection = RunService.RenderStepped:Connect(function() local rotationY = tick() % (math.pi * 2) local tiltX = math.rad(-15) -- Slight downward tilt itemDisplay:SetCFrame(CFrame.Angles(0, rotationY, 0) * CFrame.Angles(tiltX, 0, 0)) end) -- Cleanup function local function cleanup() connection:Disconnect() itemDisplay:Destroy() end ``` -------------------------------- ### Module3D:Attach3D Source: https://context7.com/thenexusavenger/module3d/llms.txt Attaches a 3D model or part to an existing Frame element, automatically managing frame sizing and camera setup. ```APIDOC ## Module3D:Attach3D(Frame, Model) ### Description Attaches a 3D model or part to an existing Frame element. This method automatically handles frame sizing to maintain a square aspect ratio, centers the ViewportFrame within the parent, and sets up event listeners to resize when the parent frame changes size. ### Method `Module3D:Attach3D` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("ItemDisplayFrame") local swordModel = ReplicatedStorage:WaitForChild("Weapons"):WaitForChild("Sword") -- Attach the model to the frame (does not clone the model) local display = Module3D:Attach3D(frame, swordModel) display.Visible = true -- The ViewportFrame automatically resizes when the parent frame changes -- and stays centered within the parent ``` ### Response #### Success Response (200) Returns a Module3D object representing the attached 3D display. #### Response Example (No specific response example provided, but it returns a Module3D instance.) ``` -------------------------------- ### Get Current Camera CFrame Offset Source: https://context7.com/thenexusavenger/module3d/llms.txt Retrieves the current CFrame offset applied to the camera. Use this to inspect or replicate the current camera's orientation. ```lua local Module3D = require(game.ReplicatedStorage:WaitForChild("Module3D")) local model3D = Module3D.new(workspace.SomeModel:Clone()) model3D:SetCFrame(CFrame.Angles(0, math.rad(45), 0)) local currentOffset = model3D:GetCFrame() print("Current rotation:", currentOffset) -- CFrame with 45 degree Y rotation ``` -------------------------------- ### Get Camera Depth Multiplier Source: https://context7.com/thenexusavenger/module3d/llms.txt Returns the current depth multiplier value applied to the camera's distance. Use this to check the current zoom level. ```lua local Module3D = require(game.ReplicatedStorage:WaitForChild("Module3D")) local model3D = Module3D.new(workspace.SomeModel:Clone()) model3D:SetDepthMultiplier(2.0) local depth = model3D:GetDepthMultiplier() print("Depth multiplier:", depth) -- Output: 2.0 ``` -------------------------------- ### Initialize Module3D with BasePart or Model Source: https://context7.com/thenexusavenger/module3d/llms.txt Creates a new Module3D instance. Automatically wraps BaseParts in a Model and positions it for display. Use this when creating a new 3D display from scratch. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) -- Create from a BasePart local part = Instance.new("Part") part.Size = Vector3.new(4, 4, 4) part.BrickColor = BrickColor.new("Bright blue") local model3D = Module3D.new(part) model3D.Parent = script.Parent.ScreenGui.Frame model3D.Visible = true -- Create from an existing Model local characterModel = ReplicatedStorage:WaitForChild("CharacterPreview"):Clone() local characterDisplay = Module3D.new(characterModel) characterDisplay.Parent = script.Parent.ScreenGui.CharacterFrame characterDisplay.Visible = true ``` -------------------------------- ### Attach and Animate 3D Model in ScreenGui Source: https://github.com/thenexusavenger/module3d/blob/master/README.md This snippet demonstrates how to attach a 3D model to a Frame within a ScreenGui using Module3D. It then sets up a RenderStepped connection to continuously animate the model's rotation. ```lua local Frame = script.Parent:WaitForChild("Frame") local Module3D = require(game.ReplicatedStorage:WaitForChild("Module3D")) local Towers = game.ReplicatedStorage:WaitForChild("Towers") local Model3D = Module3D:Attach3D(Frame,Towers) Model3D:SetDepthMultiplier(1.2) Model3D.CurrentCamera.FieldOfView = 5 Model3D.Visible = true game:GetService("RunService").RenderStepped:Connect(function() Model3D:SetCFrame(CFrame.Angles(0, tick() % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0)) end) ``` -------------------------------- ### Attach 3D Model to UI Frame Source: https://context7.com/thenexusavenger/module3d/llms.txt Attaches a 3D model or part to an existing Frame. Automatically resizes the frame to maintain aspect ratio and centers the display. Use this to integrate existing 3D assets into UI. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("ItemDisplayFrame") local swordModel = ReplicatedStorage:WaitForChild("Weapons"):WaitForChild("Sword") -- Attach the model to the frame (does not clone the model) local display = Module3D:Attach3D(frame, swordModel) display.Visible = true -- The ViewportFrame automatically resizes when the parent frame changes -- and stays centered within the parent ``` -------------------------------- ### Force Camera Update with Model3D:Update() Source: https://context7.com/thenexusavenger/module3d/llms.txt Call this method after modifying a model's parts or size to ensure the camera is correctly positioned. It forces an update to the camera's CFrame based on the model's new bounding box. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("DynamicDisplay") local model = ReplicatedStorage:WaitForChild("ExpandingObject"):Clone() local display = Module3D:Attach3D(frame, model) display.Visible = true -- After modifying the model's parts for _, part in ipairs(display.Object3D:GetDescendants()) do if part:IsA("BasePart") then part.Size = part.Size * 1.5 end end -- Force camera update to account for new bounding box display:Update() ``` -------------------------------- ### Module3D:SetDepthMultiplier Source: https://context7.com/thenexusavenger/module3d/llms.txt Adjusts the distance of the camera from the model by setting a depth multiplier. ```APIDOC ## Module3D:SetDepthMultiplier(Multiplier) ### Description Sets the multiplier for how far back the camera should be positioned from the model. Higher values move the camera further away, making the model appear smaller. The default multiplier is 1. ### Method `Module3D:SetDepthMultiplier` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("ItemFrame") local largeModel = ReplicatedStorage:WaitForChild("LargeBuilding"):Clone() local display = Module3D:Attach3D(frame, largeModel) display:SetDepthMultiplier(1.5) -- Move camera back to fit larger model display.Visible = true -- Adjust field of view for tighter framing display.CurrentCamera.FieldOfView = 30 ``` ### Response #### Success Response (200) No explicit return value mentioned, but updates the camera's depth. #### Response Example (No specific response example provided.) ``` -------------------------------- ### Access ViewportFrame Properties Directly Source: https://context7.com/thenexusavenger/module3d/llms.txt Module3D objects extend ViewportFrame, allowing direct access and modification of its properties such as BackgroundTransparency, CurrentCamera, and Visible. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("StyledDisplay") local model = ReplicatedStorage:WaitForChild("Showcase"):Clone() local display = Module3D:Attach3D(frame, model) -- Access ViewportFrame properties directly display.BackgroundTransparency = 0.5 display.BackgroundColor3 = Color3.fromRGB(30, 30, 30) display.BorderSizePixel = 2 display.BorderColor3 = Color3.fromRGB(255, 215, 0) -- Modify camera properties display.CurrentCamera.FieldOfView = 50 -- Control visibility display.Visible = true ``` -------------------------------- ### Module3D:GetDepthMultiplier Source: https://context7.com/thenexusavenger/module3d/llms.txt Retrieves the current depth multiplier value used for camera positioning. ```APIDOC ## Module3D:GetDepthMultiplier() ### Description Returns the current depth multiplier value. ### Method `Module3D:GetDepthMultiplier` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local Module3D = require(game.ReplicatedStorage:WaitForChild("Module3D")) local model3D = Module3D.new(workspace.SomeModel:Clone()) model3D:SetDepthMultiplier(2.0) local depth = model3D:GetDepthMultiplier() print("Depth multiplier:", depth) -- Output: 2.0 ``` ### Response #### Success Response (200) Returns the current depth multiplier as a number. #### Response Example ```lua -- Example output: -- Depth multiplier: 2.0 ``` ``` -------------------------------- ### Module3D:SetCFrame Source: https://context7.com/thenexusavenger/module3d/llms.txt Sets the CFrame offset for the camera, allowing adjustments to the viewed model's rotation and position. ```APIDOC ## Module3D:SetCFrame(NewCFrame) ### Description Sets the CFrame offset for the camera, allowing rotation and positioning adjustments of the viewed model. The camera CFrame is automatically updated when this method is called. ### Method `Module3D:SetCFrame` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("RotatingDisplay") local model = ReplicatedStorage:WaitForChild("Trophy"):Clone() local display = Module3D:Attach3D(frame, model) display.Visible = true -- Create a rotating display effect RunService.RenderStepped:Connect(function() local rotation = tick() % (math.pi * 2) display:SetCFrame(CFrame.Angles(0, rotation, 0) * CFrame.Angles(math.rad(-10), 0, 0)) end) ``` ### Response #### Success Response (200) No explicit return value mentioned, but updates the camera's CFrame. #### Response Example (No specific response example provided.) ``` -------------------------------- ### Set Camera CFrame Offset Source: https://context7.com/thenexusavenger/module3d/llms.txt Sets the camera's CFrame offset to adjust the rotation and position of the viewed model. Useful for creating dynamic camera effects like rotations. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("RotatingDisplay") local model = ReplicatedStorage:WaitForChild("Trophy"):Clone() local display = Module3D:Attach3D(frame, model) display.Visible = true -- Create a rotating display effect RunService.RenderStepped:Connect(function() local rotation = tick() % (math.pi * 2) display:SetCFrame(CFrame.Angles(0, rotation, 0) * CFrame.Angles(math.rad(-10), 0, 0)) end) ``` -------------------------------- ### Set Camera Depth Multiplier Source: https://context7.com/thenexusavenger/module3d/llms.txt Adjusts the distance of the camera from the model by setting a depth multiplier. Higher values make the model appear smaller. Use this to fit models of varying sizes within the frame. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("ItemFrame") local largeModel = ReplicatedStorage:WaitForChild("LargeBuilding"):Clone() local display = Module3D:Attach3D(frame, largeModel) display:SetDepthMultiplier(1.5) -- Move camera back to fit larger model display.Visible = true -- Adjust field of view for tighter framing display.CurrentCamera.FieldOfView = 30 ``` -------------------------------- ### Destroy Display and Cleanup with Model3D:Destroy() Source: https://context7.com/thenexusavenger/module3d/llms.txt Destroys the ViewportFrame and associated model, cleaning up all resources. This method also disconnects the frame resize event listener when using Attach3D. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Module3D = require(ReplicatedStorage:WaitForChild("Module3D")) local frame = script.Parent:WaitForChild("ItemPreview") local item = ReplicatedStorage:WaitForChild("Items"):WaitForChild("Helmet"):Clone() local display = Module3D:Attach3D(frame, item) display.Visible = true -- Clean up when done (e.g., when UI closes) local closeButton = script.Parent:WaitForChild("CloseButton") closeButton.MouseButton1Click:Connect(function() display:Destroy() script.Parent.Visible = false end) ``` -------------------------------- ### Module3D:GetCFrame Source: https://context7.com/thenexusavenger/module3d/llms.txt Retrieves the current CFrame offset applied to the camera view. ```APIDOC ## Module3D:GetCFrame() ### Description Returns the current CFrame offset applied to the camera view. ### Method `Module3D:GetCFrame` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local Module3D = require(game.ReplicatedStorage:WaitForChild("Module3D")) local model3D = Module3D.new(workspace.SomeModel:Clone()) model3D:SetCFrame(CFrame.Angles(0, math.rad(45), 0)) local currentOffset = model3D:GetCFrame() print("Current rotation:", currentOffset) -- CFrame with 45 degree Y rotation ``` ### Response #### Success Response (200) Returns the current CFrame offset. #### Response Example ```lua -- Example output: -- Current rotation: CFrame(0, 0, 0, 0.707106781, 0, -0.707106781, 0, 1, 0, 0.707106781, 0, 0.707106781) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.