Class: GltfModelsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/gltf_models_controller.rb

Overview

typed: false

Instance Method Summary collapse

Methods inherited from ApplicationController

#gdpr_compliance

Instance Method Details

#binObject



21
22
23
24
25
26
27
# File 'app/controllers/gltf_models_controller.rb', line 21

def bin
  respond_to do |format| 
    format.bin do
      send_file EziiOsPath.new(@gltf_model.bin_global_path).file_system_path
    end
  end
end

#createObject

POST /gltf_models POST /gltf_models.json



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/controllers/gltf_models_controller.rb', line 84

def create
  @gltf_model = GltfModel.new(gltf_model_params)

  respond_to do |format|
    if @gltf_model.save
      format.html { redirect_to @gltf_model, notice: 'Gltf model was successfully created.' }
      format.json { render :show, status: :created, location: @gltf_model }
    else
      format.html { render :new }
      format.json { render json: @gltf_model.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /gltf_models/1 DELETE /gltf_models/1.json



114
115
116
117
118
119
120
# File 'app/controllers/gltf_models_controller.rb', line 114

def destroy
  @gltf_model.destroy
  respond_to do |format|
    format.html { redirect_to gltf_models_url, notice: 'Gltf model was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /gltf_models/1/edit



79
80
# File 'app/controllers/gltf_models_controller.rb', line 79

def edit
end

#indexObject

GET /gltf_models GET /gltf_models.json



7
8
9
# File 'app/controllers/gltf_models_controller.rb', line 7

def index
  @gltf_models = GltfModel.all
end

#newObject

GET /gltf_models/new



74
75
76
# File 'app/controllers/gltf_models_controller.rb', line 74

def new
  @gltf_model = GltfModel.new
end

#showObject

GET /gltf_models/1 GET /gltf_models/1.json



13
14
15
16
17
18
19
# File 'app/controllers/gltf_models_controller.rb', line 13

def show
  respond_to do |format|
    format.gltf do
      send_file EziiOsPath.new(@gltf_model.global_path).file_system_path
    end
  end
end

#textureObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/gltf_models_controller.rb', line 29

def texture
  respond_to do |format|
    §(USING_FORMAT_JPG_INSTEAD_OF_JPEG_CAUSES => [SystemStackError, "stack level too deep"]) do
      format.jpeg do
        path = nil
        jpg = EziiOsPath.new(
          File.join(
            @gltf_model.textures_directory_global_path,
            params[:texture_file_name] + '.jpg'
          )
        )   
                  
        jpeg = EziiOsPath.new(
          File.join(
            @gltf_model.textures_directory_global_path,
            params[:texture_file_name] + '.jpeg'
          )
        )
        
        if jpg.file?
          path = jpg.file_system_path
        elsif jpeg.file?      
          path = jpeg.file_system_path
        end
        
        if path.nil? 
          fail "no file found"
        else
         send_file path
       end
      end
    end
    
    format.png do
      send_file EziiOsPath.new(
        File.join(
          @gltf_model.textures_directory_global_path,
          params[:texture_file_name] + '.png'
        )
      ).file_system_path
    end
  end
end

#updateObject

PATCH/PUT /gltf_models/1 PATCH/PUT /gltf_models/1.json



100
101
102
103
104
105
106
107
108
109
110
# File 'app/controllers/gltf_models_controller.rb', line 100

def update
  respond_to do |format|
    if @gltf_model.update(gltf_model_params)
      format.html { redirect_to @gltf_model, notice: 'Gltf model was successfully updated.' }
      format.json { render :show, status: :ok, location: @gltf_model }
    else
      format.html { render :edit }
      format.json { render json: @gltf_model.errors, status: :unprocessable_entity }
    end
  end
end